Skip to content

Core Web Vitals ​

Name the three metrics, the number each is judged at, and what you would change first for each one.

In this chapter: the 75th-percentile rule · LCP and finding the element · INP, which replaced FID · CLS and reserved space · field data against lab data · the order to fix things in

💡 The Core Idea ​

Core Web Vitals are three numbers. Each stands for one thing a user feels: did the main content arrive, did the page respond when I touched it, and did anything move under my finger.

The detail that changes how you work with them is the 75th percentile. A site is not judged on its average or on your laptop. It is judged on the visit at the 75th percentile of real users, which is a mid-range phone on a slow network. So an improvement that helps the fast half of your traffic moves the score by nothing, and a page that feels instant in development can score poorly.

That is why the vitals are a field measurement first: data from real users' browsers. Lab tools are for diagnosis. The field number is the one that counts.

⚠️ Moving target: the metric set belongs to Google, and it has already changed once (FID out, INP in). More candidates are in trial, and thresholds move too. The durable principle is the three questions under the acronyms: did the content arrive, did the page answer when touched, did anything move. Whatever the metrics are called next, they will measure those, at the 75th percentile, in the field.

How It Works ​

The three metrics and their thresholds ​

MetricMeasuresGoodPoor
LCP — Largest Contentful PaintWhen the largest visible element finished rendering< 2.5 s> 4 s
INP — Interaction to Next PaintHow long from an interaction to the next painted frame< 200 ms> 500 ms
CLS — Cumulative Layout ShiftHow much visible content moved unexpectedly< 0.1> 0.25

⚠️ FID is gone. INP replaced First Input Delay as a Core Web Vital in March 2024, and FID was removed entirely in September 2024. Much published material, and many interviewers' notes, still say FID. Being precise about this is a cheap way to sound current.

The difference is real. FID measured only the delay before the first interaction's handler started. INP measures the whole journey for every interaction: input delay, the handler running, and the browser painting the result. It reports close to the worst. A page could score well on FID while every click after it took half a second, and many did.

LCP: find the element before optimising anything ​

You cannot fix LCP without knowing which element it is, and it is often not the one you assume.

typescript
import { onLCP, type LCPMetric } from "web-vitals/attribution";

onLCP((metric: LCPMetric) => {
  // A CSS selector for the actual element, plus the phase breakdown.
  console.info(metric.value, metric.attribution.target, metric.attribution.resourceLoadDelay);
});

Then work in this order, because each fix pays off less than the one before:

FixTypical impact
Give the LCP image fetchpriority="high" and the right format and sizeLargest single win
Preload the LCP resource; preconnect to its originRemoves a discovery round trip
Remove render-blocking CSS and JavaScript from the headOften seconds on slow connections
Improve the server or CDN response timeRaises the floor for everything
html
<!-- The LCP image: modern format, right size per viewport, and not queued behind other requests -->
<img
  src="hero.avif"
  srcset="hero-400.avif 400w, hero-800.avif 800w, hero-1200.avif 1200w"
  sizes="(max-width: 600px) 400px, 1200px"
  alt="Quarterly emissions dashboard"
  fetchpriority="high"
/>

fetchpriority="high" matters more than it looks. By default the browser discovers images late and gives them low priority, so a hero image queues behind scripts it does not need to wait for.

INP: the main thread is the whole story ​

Poor INP means the main thread was busy when the user interacted. There are only three things to do about it, and all three give the thread back.

typescript
// ❌ One long task. Every click during it waits.
function reindex(rows: Row[]): void {
  for (const row of rows) expensiveWork(row);
}

// ✅ Yield between chunks so input can be handled.
async function reindex(rows: Row[]): Promise<void> {
  for (let i = 0; i < rows.length; i++) {
    expensiveWork(rows[i]);
    if (i % 100 === 0) await scheduler.yield(); // hand the thread back
  }
}
CauseFix
A single task over 50 msChunk it and yield, or move it to a worker
A handler firing on every keystroke or scroll frameDebounce or throttle it
A large synchronous re-render after a state changeNarrow what re-renders, or mark it non-urgent

Remember the 50 ms number. Any task longer than that can hold up an interaction, and the browser cannot interrupt it. See Performance, Transitions and the Compiler for the framework-level version.

CLS: reserve the space before the content arrives ​

Every layout shift has the same cause: the browser did not know how big something would be.

html
<!-- ❌ Content jumps down when the image loads -->
<img src="chart.png" alt="Emissions by quarter" />

<!-- ✅ The box exists from the first frame -->
<img src="chart.png" alt="Emissions by quarter" width="800" height="600" />

<!-- ✅ Or with intrinsic ratio, for a fluid width -->
<img src="chart.png" alt="Emissions by quarter" style="aspect-ratio: 4 / 3; width: 100%" />

The same rule covers everything that arrives late. Give an ad or embed slot a min-height. Make a skeleton the same size as the content it replaces. Pair font-display: swap with matched fallback metrics, so the text does not reflow when the web font arrives. Caching and Asset Delivery covers that pairing.

And one behaviour rule: never insert content above what the user is already reading. A notification banner belongs in a fixed overlay, not pushed into the flow.

Field data and lab data answer different questions ​

Field (real users)Lab (Lighthouse, a synthetic run)
MeasuresWhat actually happened, at the 75th percentileOne controlled load on one device
Good forKnowing whether you have a problemFinding out why
Can measure INPYesNo — there is no real interaction to measure

That last row catches people. A lab run has nobody clicking, so Lighthouse reports Total Blocking Time as a stand-in. INP only exists in the field. You cannot fix it until real-user measurement is in place. See Measuring in Production.

When to Use It ​

SituationFix firstWhy
A content or marketing page scoring badlyLCP: the hero image and render-blocking headLoad dominates; there is little interaction
A dashboard or editor scoring badlyINP: long tasks and re-render costThe user interacts constantly
Ads, embeds or late-loading bannersCLS: reserve every slotOne unreserved slot can fail the metric alone
Good lab scores, poor field scoresTrust the field, and segment itYour device is not the 75th percentile
Poor INP with no field dataInstrument firstINP cannot be measured in a lab run

Common Mistakes ​

❌ Optimising the average. Improving the fast half of traffic moves the 75th percentile by nothing. ✅ Segment field data by device and connection, and work on the slow tail.

❌ Talking about FID. It stopped being a Core Web Vital in 2024. ✅ INP, and be able to say what it measures that FID did not.

❌ Guessing the LCP element. Teams often optimise an image that is not it. ✅ Read it from attribution data, then optimise that one element.

❌ loading="lazy" on the hero image. It defers the exact resource LCP is waiting for. ✅ Eager, with fetchpriority="high". Lazy-load only below the fold.

❌ Chasing a Lighthouse score as the goal. It is one simulated load, and it cannot see INP at all. ✅ Use lab runs to diagnose, and judge on field data.

🔑 Key Takeaways ​

  • Core Web Vitals are judged at the 75th percentile of real users, not on an average or your own device.
  • INP replaced FID in 2024: it measures every interaction end to end, not just the first input's delay.
  • LCP work starts by identifying the element from attribution data, not by guessing.
  • Every layout shift comes from unreserved space, so give late-arriving content its box up front.
  • INP cannot be measured in a lab run, which makes real-user monitoring a prerequisite for fixing it.

Interview Questions ​

Q: What replaced FID, and what does it measure differently?

INP, as of March 2024. FID only measured the delay before the first interaction's handler began. A page could score well and still feel slow on every click after the first. INP measures the full path (input delay, handler run, and next paint) across all interactions, and reports close to the worst one. It is much harder to game, and a much better guide to how the page actually feels.

Q: A page has an LCP of 4.2 seconds. Walk me through your first hour.

Identify the LCP element from field attribution rather than assuming. It is often a background image or a headline instead of the hero. Then check the sequence: is the resource discovered late, queued behind scripts, or just too large? Most of the time the fix is the right format and size, plus fetchpriority="high" and a preload. Only after that would I look at render-blocking CSS or the server's response time.

Q: Why can Lighthouse not tell you your INP?

Because there is no user in a lab run. INP needs real interactions to measure, so Lighthouse reports Total Blocking Time instead, as a stand-in for a busy main thread. That is why fixing INP starts with getting field data in place. Without it, you are optimising a number that correlates with the metric but is not the metric.

Q: Your CLS is 0.3 and you have set width and height on every image. Where else do you look?

Late-arriving content that has no reserved box: ad and embed slots, cookie banners inserted into the flow, consent modals, and anything added above the current scroll position. Then web fonts. A fallback with different metrics reflows every line when the real font swaps in. The fix needs size-adjust and matched ascent and descent, not just font-display: swap.

The whole book, free to read. Generated from the manuscript on every change.

Your progress

Tick each chapter in the sidebar once you have read and understood it. Your name and email keep the ticks on any device.

Your name and email are stored to save your progress. Nothing else is done with them.