Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Size of JS scripts in production / components lazy loading

Hello,

To build the app in production : npm run build.

With vue router it's possible to lazy load the component, so that the files to load become smaller.

But the vendor JS script is always about 6 Mb.

Is there a way to descrese the size of the vendor JS script ?

And when is it really worth splitting the files by lazy loading the components ? From which size of files ?

Thanks for your answer.

Vincent

0 likes
6 replies
sr57's avatar
sr57
Best Answer
Level 39

@vincent15000

I have better "code splitting" than "lazy loading" concerning js , nothing can be done automatically, it depends of your app, your code and mainly the UX/UI you want.

That said, your question makes me to search on the web for a better answer than these 2 lines and I found this link; not too long, complete and clear.

https://calibreapp.com/blog/bundle-size-optimization

1 like
sr57's avatar

@vincent15000

I appreciate your question, it makes me go deeper in this important point.

1 like
vincent15000's avatar

@sr57 I don't know if it's a good idea and I don't want to test it for the moment, but I wonder if there is a way to bundle only the needed node modules and not all the others that are not used in the app.

1 like

Please or to participate in this conversation.