Performance: Parallel data fetching
HIGH IMPACT
This affects page load speed by reducing the time waiting for multiple data sources to respond, improving the Largest Contentful Paint (LCP).
const [data1, data2, data3] = await Promise.all([ fetch('/api/data1').then(res => res.json()), fetch('/api/data2').then(res => res.json()), fetch('/api/data3').then(res => res.json()) ]);
const data1 = await fetch('/api/data1').then(res => res.json()); const data2 = await fetch('/api/data2').then(res => res.json()); const data3 = await fetch('/api/data3').then(res => res.json());
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Sequential fetches | Minimal | 1 (after all data) | High (delayed paint) | [X] Bad |
| Parallel fetches with Promise.all | Minimal | 1 (after all data) | Low (faster paint) | [OK] Good |