codeWisperer
codeWisperer

Reputation: 86

loading libraries when they are needed and not on first load?

how can i load a library just when it is needed , as in when the user gets to a page that uses it ?

in my case i have a page on the vuejs app that needs a Three.js element, including the library in the index.html seems to increase initial load time too much

i am coding a vue.js (2.x) program under vue-cli with PWA template https://github.com/vuejs-templates/pwa

i am trying to avoid slow initial load times for the app, any suggestions to achieve this with a big library such as three.js would be appreciated thank you

Upvotes: 0

Views: 169

Answers (1)

Smiling Sloth
Smiling Sloth

Reputation: 98

It seems what you are lloking for is Code Splitting feature from webpack. You can refer webpack docs for more details. But if you need to understand in short you can take look in these blogs:

Code Splitting With Vue.js And Webpack

3 Code Splitting Patterns For VueJS and Webpack

Upvotes: 1

Related Questions