Chapter 5 · Performance
Interview drill
7 questions from this chapter. Answer each one out loud first, then open it to compare.
-
5.1"Which metric would you optimise first, and why?"
- Start with LCP, because it usually shares a root cause with TTFB and render-blocking resources — one fix moves several numbers.
- Then INP, since main-thread work is what makes an app feel broken even after it looks loaded.
- CLS is usually the cheapest fix of the three: dimensions on media and reserved space for late-injected content.
-
5.2"How do you justify a performance sprint to a product manager?"
- Convert the metric into their language: p75 LCP, the conversion delta measured or benchmarked, and the revenue that implies.
- Show the device gap — most stakeholders have never seen the site on a mid-tier Android on 4G.
- Ask for a budget in CI instead of a one-off sprint, so the win doesn't erode by the next quarter.
-
5.3"Lighthouse says 98. Users say it's slow. Who's right?"
- Both — Lighthouse measures one simulated device, field data measures the population.
- Look at p75 and p95 by device class and route; the regression is almost always concentrated somewhere specific.
- Keep lab for gating merges and field for alerting; using either alone leaves a blind spot.
-
5.4"Walk me through debugging a slow page."
- Throttle, reload, open the waterfall, and find what delays the LCP element's start time.
- Chains and render-blocking resources first; only then look at bundle size and main-thread work in the flame chart.
- Verify on a real mid-tier device, then lock the win in with a CI budget (4.5) so it doesn't regress.
-
5.5"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.
-
5.6"SSR or CSR for an e-commerce site?"
- Per route: product and category pages need SEO and fast LCP → SSG/ISR at the edge; cart and account are CSR behind login.
- Price and stock are the genuinely dynamic bits — fetch those client-side or stream them into a static shell.
- Name hydration cost explicitly: SSR that ships a huge bundle can feel slower than CSR despite a better LCP.
-
5.7"Your bundle is 500KB. Where do you start?"
- Open the treemap first — in most apps two or three dependencies own half the weight.
- Route-split, replace the heavyweights, verify tree shaking is actually happening (named ESM imports,
sideEffects). - Lock it in with a
size-limitgate in CI (4.5), or it grows straight back next quarter.