I have a vue.js router implemented and if I run npm run build it correctly creates separate files for every component. But if I run npm run serve and then open the page all components files are loaded immediately not lazy. If I click on the link to component it loads the components file again. I don't understand why it is not lazy. Look at the screenshot. There are contact.js (which should be chunk) loaded two times. First on refresh second on link click.
1 Answer
it's called prefetching. vue-cli 3 does this by default as explained here.
Regarding the chunk being loaded twice, I suggest that you build in production mode and then check the actual response of both the duplicate requests. I think the second time, the chunk only gets loaded from browser cache and does not make a network request

vue-cli3 does this by default: cli.vuejs.org/guide/html-and-static-assets.html#prefetch Regarding the chunk being loaded twice, I suggest that you build in production mode and then check the actual response of both the duplicate requests. I think the second time, the chunk only gets loaded from browser cache and does not make a network request