0
0
Astroframework~8 mins

client:idle for deferred hydration in Astro - Performance & Optimization

Choose your learning style9 modes available
Performance: client:idle for deferred hydration
MEDIUM IMPACT
This affects the time it takes for interactive content to become usable by deferring hydration until the browser is idle.
Hydrating interactive components without blocking initial load
Astro
<MyComponent client:idle />
Hydration waits until browser is idle, reducing main thread blocking during load.
📈 Performance GainImproves INP by deferring hydration, reducing input delay by 100-300ms
Hydrating interactive components without blocking initial load
Astro
<MyComponent client:load />
Hydration starts immediately after load, blocking main thread and delaying interactivity.
📉 Performance CostBlocks main thread during load, increasing INP by 100-300ms
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
client:load hydrationMultiple DOM updates during hydrationTriggers 1 reflow per component hydrated immediatelyModerate paint cost during load[X] Bad
client:idle hydrationDOM updates deferred until idleSingle reflow during idle hydrationPaint cost spread out, less blocking[OK] Good
Rendering Pipeline
The browser loads HTML and CSS, paints static content quickly, then waits for idle time to hydrate interactive components, minimizing main thread blocking during critical rendering.
JavaScript Execution
Main Thread
Interaction Readiness
⚠️ BottleneckMain Thread blocking during hydration
Core Web Vital Affected
INP
This affects the time it takes for interactive content to become usable by deferring hydration until the browser is idle.
Optimization Tips
1Defer hydration to idle time to reduce main thread blocking during load.
2Use client:idle to improve input responsiveness (INP) by spreading hydration work.
3Expect a slight delay in interactivity but better overall user experience.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main benefit of using client:idle for hydration in Astro?
AIt disables hydration completely.
BIt defers hydration until the browser is idle, reducing main thread blocking.
CIt hydrates components immediately after page load.
DIt hydrates components only on user interaction.
DevTools: Performance
How to check: Record a performance profile during page load and interaction; look for long tasks blocking main thread and hydration timing.
What to look for: Check for reduced main thread blocking during load and hydration tasks occurring during idle periods.