Performance: Page load functions (+page.js)
MEDIUM IMPACT
This affects the initial page load speed by controlling data fetching before the page renders.
export async function load({ fetch }) { const res = await fetch('https://api.example.com/summary-data'); const data = await res.json(); return { data }; }
export async function load() { const res = await fetch('https://api.example.com/large-data'); const data = await res.json(); return { data }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Sequential fetch in +page.js | Minimal DOM changes | 1 reflow after data arrives | Paint delayed by data fetch | [X] Bad |
| Parallel fetch with Promise.all | Minimal DOM changes | 1 reflow after data arrives | Paint happens sooner | [OK] Good |