FSD Frontend System Design

Chapter 5 · Performance

Revision sheet

Every lesson's idea and recap on one page. Read it before an interview, or print it.

  1. 5.1Performance Overview

    Three metrics describe what a user feels: is it there, does it respond, does it stay still.

    • There, responsive, stable — LCP, INP, CLS.
    • One main thread does parsing, JS, layout, and paint; long tasks freeze all of it.
    • Always p75 of real users, never a single lab run.
  2. 5.2Performance Importance

    Latency is a business metric — it moves conversion, retention, and reach, not just Lighthouse scores.

    • Performance is revenue, retention, and reach — argue it in those terms.
    • Your users' devices are several times slower than yours; test that way.
    • Biggest gains are at the slow end of the curve; know where you sit.
  3. 5.3Performance Monitoring

    Lab tests tell you what changed; field data tells you what users actually got.

    • Synthetic gates changes; RUM tells the truth.
    • Report p75 and p95 with dimensions attached — averages hide the users who leave.
    • sendBeacon on page hide, or you lose the metrics that matter most.
  4. 5.4Performance Tools

    Read the waterfall before you read the code — the shape of the chart names the bottleneck.

    • Waterfall first: a staircase means a dependency chain, and that's the biggest lever.
    • Flame chart for anything after first paint — wide blocks are frozen UI.
    • Throttle every measurement, or you're debugging a page your users never see.
  5. 5.5Network Optimization

    Fewer round trips, closer bytes, fewer bytes — in that order, because that's the order of impact.

    • 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.
  6. 5.6Rendering Patterns

    Where and when HTML gets built — CSR, SSR, SSG, ISR, streaming — decides your LCP before you write a line.

    • The pattern is chosen per route, by freshness and personalisation.
    • Hydration is the hidden cost — looking ready isn't being ready.
    • Static shell + streamed dynamic parts is the default answer for most content sites.
  7. 5.7Build Optimization

    Ship only the code this route needs, compress it, and let the browser cache it forever.

    • Measure the treemap, split by route, replace heavy dependencies, compress.
    • Tree shaking needs ESM and honest sideEffects — CommonJS silently defeats it.
    • Hashed filenames plus immutable caching make repeat visits nearly free.

Capstone

Take a page with a 6-second LCP under 2.5s. List every change you made and the milliseconds each one saved.