vue-router lazy loading routes reduces performance #7091
Replies: 2 comments 1 reply
-
dynamic imports introduce a certain lag, as they need to be loaded in a second step, after the entry file has been loaded from the backend. So they don't make things faster on their own. They only become a performance benefit if you have many routes, and import each one dynamically, instead of bundling all of those routes in one giant initial bundle. You could even do a mixed setup where you statically import i.e. the homepage into the initial bundle because this needs to be very performant, and then load other routes dynamically in order to keep the initial bundle lightweight. |
Beta Was this translation helpful? Give feedback.
-
I have a similar problem, it can take multiple seconds to load lazy routes, which is largely unworkable 😬 . |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I use vite's vuejs3, and performance rate with lighthouse will become much lower when I use lazy loading route from vue-router.
The built performance for the homepage with dynamic import is 75.
The built performance fort the homepage with static import is 90.
I don't the actual reasoning behind this. The performance should be increasing instead of decreasing.
dependencies:
"vue-router": "^4.1.5",
"@vitejs/plugin-vue": "^3.1.0",
"typescript": "^4.6.4",
"vite": "^3.1.0",
"vue-tsc": "^0.40.4"
Beta Was this translation helpful? Give feedback.
All reactions