Core Web Vitals — Performance

There are three Core Web Vitals: LCP (when the biggest content shows, good at most 2.5 seconds, poor above 4 seconds), INP (how fast the screen changes after…

Three things annoy people on a web page: the content takes long to show up, a button is slow to answer a tap, and the layout jumps around. The last one is the worst. You're about to tap "Buy", a banner appears above it, the button drops, and you hit an ad instead.

Google measures all three with numbers called Core Web Vitals, which grade how it feels to use your page: how fast the main content shows up (LCP), how quickly the page responds to a click (INP), and how still the page stays while it loads (CLS). Picture a report card with three required subjects. Each subject has a passing mark, and a single red mark is enough to fail the report.

The three metrics

INP replaced FID (First Input Delay) in March 2024. FID only measured the wait before the first interaction started being handled. INP measures every interaction, until the screen actually changes.

The limits: good, needs improvement, poor

Metric Good Needs improvement Poor
LCP at most 2.5 seconds above 2.5 up to 4 seconds above 4 seconds
INP at most 200 ms above 200 up to 500 ms above 500 ms
CLS at most 0.1 above 0.1 up to 0.25 above 0.25

"At most" means a number exactly on the limit is still good. So a page with an LCP of 2.5 seconds, an INP of 200 ms and a CLS of 0.1 still passes: all three are good.

Google doesn't grade a single visit but real visits at the 75th percentile (p75): sort all the visits from fastest, then take the value at the 75% mark. That means at least 75% of visits must be good for the page to count as good. Google uses the result as one of its ranking signals in search.

Grading all three at once

In the exercise, LCP and INP are in milliseconds (2.5 seconds is 2500), and CLS is a decimal number. In JavaScript, the decimal point is a dot: 0.1.

function gradeMetric(value, goodMax, needsMax) {
  if (value <= goodMax) return "good";
  if (value <= needsMax) return "needs-improvement";
  return "poor";
}

function gradeWebVitals(lcp, inp, cls) {
  const grades = [
    gradeMetric(lcp, 2500, 4000), // LCP in ms
    gradeMetric(inp, 200, 500),   // INP in ms
    gradeMetric(cls, 0.1, 0.25),  // CLS has no unit
  ];

  if (grades.includes("poor")) return "failed";
  if (grades.every((grade) => grade === "good")) return "passed";
  return "needs-improvement";
}

console.log(gradeWebVitals(3000, 150, 0.05)); // "needs-improvement"
Call LCP INP CLS Result
gradeWebVitals(2000, 150, 0.05) good good good "passed"
gradeWebVitals(3000, 150, 0.05) needs-improvement good good "needs-improvement"
gradeWebVitals(5000, 100, 0.05) poor good good "failed"
gradeWebVitals(2500, 200, 0.1) good good good "passed"

The most common causes

Each cause has its own lesson in this track. Here it's enough to know which metric gets hit.

⚠️ Misreading the Core Web Vitals report card

TL;DR: There are three Core Web Vitals: LCP (when the biggest content shows, good at most 2.5 seconds, poor above 4 seconds), INP (how fast the screen changes after an interaction, good at most 200 ms, poor above 500 ms) and CLS (how much the page shifts, good at most 0.1, poor above 0.25). INP replaced FID in March 2024. Google grades at the p75 of real visits. To grade all three: a single poor means "failed", all good means "passed", anything else is "needs-improvement", and a number exactly on a limit is still good.

⚡ Three metrics, one report card

Meaning: LCP is when the largest element on the first screen has finished showing. INP is how quickly the screen changes after a click, tap or key press. CLS is how much the page shifts on its own. INP replaced FID in March 2024.

⚡ The good limits

Guess first: to count as good, how long can your page's LCP be at most?

At most 2.5 seconds. A good INP is at most 200 ms, and a good CLS at most 0.1. A number exactly on the limit is still good.

Meaning: Above 4 seconds (LCP), 500 ms (INP) or 0.25 (CLS) is poor. Google grades at the p75 of real visits, so at least 75% of visits must be good.

⚡ One red mark fails

Write:

if (grades.includes("poor")) return "failed";
if (grades.every((grade) => grade === "good")) return "passed";
return "needs-improvement";

Meaning: A single poor metric is enough for "failed". All three good gives "passed", anything else "needs-improvement". In the exercise, LCP is written 2500 (milliseconds), not 2.5.

What you will learn