maoberlehner / vue-lazy-hydration

Lazy Hydration of Server-Side Rendered Vue.js Components
MIT License
1.18k stars 52 forks source link

Question: exclude async components from init load #110

Open Kolobok12309 opened 3 years ago

Kolobok12309 commented 3 years ago

I use this package and it worked well with hydration and async componnets. But can i exclude some async components, from initial html scripts? I have NavBar with some only mobile and only desktop elements, but nuxt load all of them(hydration work as expected)

Kolobok12309 commented 3 years ago

Reproduce Code Page

If you go to page link, you can see script /_nuxt/tutorial-lazy.js in ssr html, but component async I know that vue-lazy-hydration not call it, check it in console. For some components it work as expected(load only when trigger hydration)

paulnta commented 3 years ago

This issue is more related to vue-server-renderer which Nuxt.js depends on. If an async script is used on the server when rendering the page, vue-server-renderer will automatically inject it into the HTML.

So you are looking for a way to tell vue-server-renderer to not automatically render some async scripts. This is being disscussed (since a long time 😄 ) in this issue and this PR