Part III — The Speed · Lesson 5.5
Network Optimization
In one lineFewer round trips, closer bytes, fewer bytes — in that order, because that's the order of impact.
Where you've seen itThe hero image that only starts downloading once the JavaScript that references it has parsed.
Diagram
BYTES — the cheap wins, ranked
1. images AVIF/WebP · responsive srcset · lazy-load below fold
(images are typically 50%+ of page weight)
2. compress Brotli > gzip for text · ~15% smaller
3. fonts woff2 · subset · font-display: swap · max 2 weights
4. JS see 5.7 — usually the hardest and most valuableHow it works
- Cut round trips first.
preconnectto third-party origins,preloadthe LCP resource and fonts, and break dependency chains so requests start in parallel. - Move bytes closer. A CDN turns a 200ms origin fetch into a 30ms edge hit for everything cacheable.
- Then cut bytes. Modern image formats, Brotli, subset fonts, and route-level code splitting.
- Set
fetchpriorityto tell the browser which image matters —highon the hero,lowon carousels below the fold. - Lazy-load below the fold with
loading="lazy"on images and iframes, but never on the LCP element.
<link rel="preconnect" href="https://cdn.example.com">
<link rel="preload" as="image" href="/hero.avif" fetchpriority="high">
<img src="/hero.avif" width="1200" height="600" alt="…"
fetchpriority="high"> <!-- LCP: never lazy -->
<img src="/below.avif" width="400" height="300" alt="…"
loading="lazy" decoding="async">Trade-offs
| Technique | Win | Watch out |
|---|---|---|
preconnect | 1–2 RTT per origin | Limit to 3–4; each costs a socket |
preload | Starts LCP resource immediately | Over-use starves other requests |
| CDN | 100–300ms per request | Cache invalidation strategy |
| Brotli | ~15% over gzip | Slower to compress — do it at build time |
loading="lazy" | Fewer bytes on first load | Applied to the LCP image, it hurts |
Interview angle
"The hero image is the LCP element and it's slow. Fix it."
- First ask when it starts, not how long it takes — usually it's discovered late inside CSS or JS.
preloadwithfetchpriority="high", serve AVIF/WebP withsrcset, and set explicit dimensions to protect CLS.- Then check the origin: a slow TTFB delays everything downstream regardless of image size.
Recap
- Round trips beat bytes; discovery order beats file size.
- Preload the LCP image and fonts, preconnect to third-party origins, cap both.
- Never lazy-load the LCP element — the single most common self-inflicted regression.