Performance: Route prefetching behavior
MEDIUM IMPACT
Route prefetching affects page load speed by loading page code and data before the user navigates, improving perceived navigation speed.
import Link from 'next/link'; export default function Nav() { return ( <nav> <Link href="/about">About</Link> <Link href="/contact">Contact</Link> <Link href="/products">Products</Link> </nav> ); }
import Link from 'next/link'; export default function Nav() { return ( <nav> <Link href="/about" prefetch={true}>About</Link> <Link href="/contact" prefetch={true}>Contact</Link> <Link href="/products" prefetch={true}>Products</Link> </nav> ); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager prefetch all links | Minimal | 0 | Increased due to delayed main content | [X] Bad |
| Automatic viewport-based prefetch | Minimal | 0 | Minimal paint delay, faster navigation | [OK] Good |