When I'm using Lazy load with nuxt and components: true
For example
<div v-if="condition"> <!-- 1 -->
<LazyComponent v-if="condition"/>
</div>
<div v-if="condition"> <!-- 2 -->
<LazyComponent/>
</div>
<div v-if="condition"> <!-- 3 -->
<Component/>
</div>
The v-if should be on the component in order to lazy load or it will work when parent has the condition, if it will work with the parent the component must start with Lazy
?
I am using vue-lazy-hydration package in order to decrease my Time to Interactive and Total Blocking Time. When (LazyHydrate when-idle) take action I don't understand when the browser is idle.
Here a tweet about the subject, recommending a v-if
on the component itself.
To make a recap on all of the 3 cases that you do have here:
v-if
on component + Lazy)So, pretty much:
lazy
pretty much every component that you want to import, it's rarely a bad ideav-if
directly on the componentv-if
on the parent tag, Nuxt can somehow still achieve to make it work (double-check your network tab to be sure: build your app and inspect the JS loaded when the v-if
condition is met)A browser is idle when there is nothing happening on the website (CPU-wise) as explained by this answer. This answer may also be useful IMO.
Also, I think that this idle is something totally different and unrelated.
PS: last time I checked Markus' project (vue-lazy-hydration), it wasn't compatible with Nuxt2.