Performance: When to hydrate vs keep static
HIGH IMPACT
This concept affects page load speed and interaction responsiveness by deciding when JavaScript activates on the page.
import MyWidget from './MyWidget.astro'; <MyWidget client:idle />
import MyWidget from './MyWidget.astro'; <MyWidget client:load />
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Hydrate entire page immediately | High (many nodes hydrated) | Multiple reflows | High paint cost due to JS | [X] Bad |
| Hydrate interactive widgets on idle | Moderate (only widgets) | Single reflow | Lower paint cost | [OK] Good |
| Keep static content without hydration | Low (static DOM) | No reflows from JS | Minimal paint cost | [OK] Good |