Performance: client:load directive
This affects the page's initial load speed by deferring JavaScript execution until after the page is fully loaded.
<MyComponent client:load />
<MyComponent client:idle />
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| client:load | Minimal extra DOM nodes | Triggers 1 reflow after load | Paint cost delayed but minimal | [OK] Good |
| client:idle | Minimal extra DOM nodes | Reflows delayed until idle | Paint cost delayed, may cause input lag | [!] OK |
| client:visible | Minimal extra DOM nodes | Reflows triggered on visibility | Paint cost depends on scroll | [!] OK |
| Static (no directive) | Minimal extra DOM nodes | No reflows from JS | No additional paint cost | [✓] Best |
client:load directive do in Astro?client:loadclient:load waits for the whole page to finish loading.client:load delays loading = A [OK]client:load on a component named MyWidget?client:load as an attribute on components.<MyWidget client:load /> is valid and concise for components without children.<MyWidget client:load />
client:load directive delays loading the component until after the full page load event in the browser.<MyWidget client-load />
client-load instead of the required colon client:load.client:load with a colon, not a dash. -> Option Bclient:load delays loading until after the page fully loads, fitting the need perfectly.client:idle waits for browser idle, client:visible waits for scroll visibility, and no directive loads immediately.Pass the test and this pattern moves unknown