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
- LCP (Largest Contentful Paint): the time from the page starting to open until the largest element on the first screen has finished showing. Usually the hero image, or a big heading or paragraph. In short: when the main content is visible.
- INP (Interaction to Next Paint): the time from a user clicking, tapping or pressing a key until the screen shows the result in the next frame. INP watches every interaction while the page is open, and reports the slowest one (when there are very many interactions, a few of the most extreme are ignored).
- CLS (Cumulative Layout Shift): how much the page's content moves without being asked to, such as text jumping down because an ad appears above it. It isn't measured in seconds but as a score with no unit. Shifts within 0.5 seconds after a user clicks or types don't count, because the user asked for them.
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" |
gradeMetricis used three times with different limits, so the good, needs-improvement, poor rule is written only once.<=puts a number exactly on a limit in the better grade.grades.includes("poor")is checked first: one red mark is enough for"failed".grades.every(...)istruewhen all three are"good". Outside those two cases, the result is"needs-improvement".
The most common causes
- Slow LCP: a big hero image, CSS and scripts that hold rendering back, or a server that takes long to answer.
- Slow INP: heavy JavaScript running in an event handler, so the browser has no chance to draw again.
- High CLS: images without
widthandheight, banners or ads inserted after the page shows, or a font whose size differs from its fallback font.
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
- Using
<at the good limit. Withlcp < 2500, an LCP of 2,500 becomes needs-improvement when it should be good. Use<=. - Only checking LCP. An INP of 600 ms or a CLS of 0.3 also means
"failed", even when LCP is fine. - Mixed units. The LCP limit in the exercise is
2500(milliseconds), not2.5(seconds). - Still talking about FID. FID was retired in March 2024. The responsiveness metric now is INP.
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.