Kayavak / The Web Frontend / FE·27 Frontend Performance / Deeper
Deeper · The Web Frontend
Frontend Performance
The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.
Why does this exist?
In 2007 Steve Souders, then at Yahoo, published High Performance Web Sites and made a finding that redirected the field: most of the time users waited was spent in the browser (downloading, parsing, waiting on scripts), not on the server. His rules (fewer requests, cache, put scripts at the bottom) and the YSlow tool started frontend performance as a discipline.
Measuring it well took longer. Lab tools gave numbers that didn't match what real users felt, and metrics such as "onload" didn't reflect when a page looked ready. In 2020 Google introduced Core Web Vitals, three field metrics measured on real users' devices: loading (LCP), responsiveness and visual stability (CLS). Responsiveness was first measured by First Input Delay, which only covered the first interaction; Interaction to Next Paint replaced it in March 2024, because the slowest interactions usually come later. Their use as a search ranking signal (from 2021) made businesses care.
The mental model
Try it yourself first: write your own model in the Mental Model Explorer, then compare.
Performance is what real users on real devices experience, at the slow end (the 75th percentile), not what your laptop shows. Each metric breaks into phases; fix the largest phase.
| Question | Answer |
|---|---|
| What is it? | How fast a page loads, responds and stays stable for the people using it |
| Problem it solves | Slow pages lose users, and the slowest experiences fall on the poorest devices and networks |
| Parts | Metrics (LCP, INP, CLS, TTFB), JavaScript cost, assets (images, fonts), runtime work, field vs lab data |
| How it works | Measure in the field, find which phase of which metric dominates, fix that, measure again |
| Assumptions | Your test conditions resemble your users' |
| When they change | A fast developer machine on office Wi-Fi hides problems a median phone on mobile data hits every day |
| Where it fails | Averages hide the slow tail; lab scores can improve while field metrics don't |
| Related ideas | Rendering pipeline (ch18); caching (ch19); measuring before changing (The Backend, memory and performance) |
What if?
What if you optimised for the average instead of the 75th percentile?
Reason it through, then open
The average is pulled down by your fastest users (good phones, fast connections), so it can look fine while a quarter of your users wait several times longer. Percentiles describe how many people get a bad experience. Core Web Vitals use p75 so that most visitors, including slower ones, are covered.
What if JavaScript were free to download?
Reason it through, then open
It still wouldn't be free to run. Each kilobyte of JavaScript must be parsed, compiled and executed on the main thread, and on a low-end phone that can take several times longer than on a laptop. Image bytes, by contrast, mostly decode off the main thread. That's why shipping less JavaScript helps responsiveness far more than shrinking images by the same number of bytes.
Where the boundary is
| Aspect | Lab data | Field data (RUM) |
|---|---|---|
| Comes from | One controlled run (Lighthouse, WebPageTest) | Real visits (Chrome UX Report, your own monitoring) |
| Good for | Debugging, comparing before and after a change | Knowing what users actually experience |
| Measures INP? | No: needs real interactions (TBT is a proxy) | Yes |
| Misleads when | Conditions differ from users' | Traffic is small or skewed |
How sure are we?
| Claim | How it's known | Where from |
|---|---|---|
| Most user wait time is spent in the frontend | Measured, historically | Souders' measurements in 2007; still often true, though server time matters again with SSR |
| INP replaced FID as a Core Web Vital in March 2024 | Historical | Google's announcement |
| Slower pages lose users and revenue | Measured | Many company case studies; effect sizes vary and some are marketing figures |
| Fix the largest phase first | Model | Amdahl's reasoning applied to page loads |
Still open
Whether the web keeps getting heavier is a running measurement: the median page has kept growing in JavaScript for over a decade (HTTP Archive). How to measure responsiveness in single-page apps' soft navigations is still being standardised.
What would change your mind? If users on low-end devices were rare in your audience, optimising for them would matter less, but measure first: your analytics may not see users who gave up before the page loaded.
Recall
What do the three Core Web Vitals measure?
LCP loading, INP responsiveness, CLS visual stability.
Why use the 75th percentile rather than the average?
The average hides the slow experiences of a large minority of users.
Why is JavaScript more expensive than images of the same size?
It must be parsed, compiled and run on the main thread, blocking interaction.
What replaced First Input Delay, and why?
Interaction to Next Paint (March 2024), because it measures all interactions, not just the first.
Reflect
Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.