I have a website written in Laravel and InertiaJS (VueJS).
It has more than 60 pages.
InertiaJS stores all pages and components in these three files:
/js/manifest.js
/js/vendor.js
/js/app.js
The problem is the size of these files (Specially app.js
) are getting so huge! The app.js
is about 5MB.
I removed useless plugins and libraries, Also i refactored my code and it’s all clean.
When i was only using Laravel for web development, I could load each page javascript and css files in it’s own page. So speed of the page was pretty good. But when i migrated to VueJS it loads app.js and styles.css at once! It also extracts all styles in one file which is not ideal.
Also i use CDN, gzip compression, SSR and they are not helping too much to have better performance.
I want extract all components and pages into different javascript/css files and load them in their own pages when needed.
How can i do that ?
2
Answers
Are you loading all the pages at once?
I think you can try loading components only if required. We can use lazy loading and reduce
app.js
. Ref: https://router.vuejs.org/guide/advanced/lazy-loading.html#with-webpackThis is my app.js file.
Here’s your app.js using code splitting. See if it’ll reduce your load size:
See this: Inertia doc