Performance: Mocking data fetching
MEDIUM IMPACT
Mocking data fetching affects page load speed and interaction responsiveness by simulating network calls without real server delays.
export async function getServerSideProps() { const data = { id: 1, name: 'Mocked Item' }; return { props: { data } }; }
export async function getServerSideProps() { const res = await fetch('https://api.example.com/data'); const data = await res.json(); return { props: { data } }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Real network fetch on each load | Minimal | 1 reflow after data arrives | Moderate paint cost due to delayed content | [X] Bad |
| Mocked data returned immediately | Minimal | 1 reflow immediately | Low paint cost with instant content | [OK] Good |