CSS not loaded for not hydrated components with lazy hydration - is this expected? #14168
Replies: 1 comment
-
|
Yes, this is expected behavior with Vue's lazy hydration (hydrate-on-visible). Why CSS isn't loaded: When using Solutions:
<!-- parent or global CSS -->
<style>
.lazy-component-placeholder {
min-height: 300px; /* or whatever the expected height is */
}
</style>
// Load CSS immediately, hydrate component lazily
import './MyComponent.css'
const MyComponent = defineAsyncComponent({
loader: () => import('./MyComponent.vue'),
hydrate: hydrateOnVisible()
})
<Suspense>
<template #default><LazyComponent /></template>
<template #fallback><Skeleton height="300px" /></template>
</Suspense>For anchor scroll issues specifically: You might also consider using The fundamental tradeoff: lazy hydration saves bandwidth but defers CSS loading. Critical layout styles need to be available synchronously. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We have some components that hydrate on visible and have no styling prior to hydration. This causes # links to not scroll to the correct position since hydrate-on-visible components change their height mid-scroll.
Beta Was this translation helpful? Give feedback.
All reactions