Performance: client:idle for deferred hydration
This affects the time it takes for interactive content to become usable by deferring hydration until the browser is idle.
<MyComponent client:idle />
<MyComponent client:load />
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| client:load hydration | Multiple DOM updates during hydration | Triggers 1 reflow per component hydrated immediately | Moderate paint cost during load | [X] Bad |
| client:idle hydration | DOM updates deferred until idle | Single reflow during idle hydration | Paint cost spread out, less blocking | [OK] Good |
client:idle directive do in Astro components?client:idle waits for the browser to be idle before hydrating a component.client:idle does.client:idle in an Astro component?client:idle with a colon, not dashes or underscores.<Counter client:idle />
client:idle directive delays hydration until the browser is idle.client:visible, not idle.<Widget client:idle>Click me</Widget>
client:idle and ensures accessibility?client:idle defers hydration until idle, improving page speed.aria-label provides a descriptive label for screen readers, maintaining accessibility.<ChatWidget client:idle /> without aria-label because hydration delays interaction anyway. lacks accessibility label. Use <ChatWidget client:load aria-hidden='true' /> to hydrate immediately but hide from screen readers. hydrates immediately and hides from screen readers, reducing accessibility. Use <ChatWidget client:idle tabindex='-1' /> to defer hydration and remove keyboard focus. removes keyboard focus, harming accessibility.Pass the test and this pattern moves unknown