Core Web Vitals in Depth
The Performance overview introduced the three Core Web Vitals. This lesson opens them up. Each is built from smaller parts, and each part has a different cause and a different cure. Once you can see the parts, a vague "the page is slow" becomes a specific list of things to fix, and you will notice that almost every lesson in this section moves one of the three numbers.
What You Will Learnβ
- What LCP, INP, and CLS each measure, and what counts
- The parts that make up LCP and INP
- How a layout shift is scored
- The HTML changes that improve each metric
- The difference between lab data and field data
- How to measure the vitals on your own pages
- How the lessons in this section map to the three numbers
The Big Ideaβ
Each vital asks one question about the visitor's experience:
| Metric | The question | Good | Needs improvement | Poor |
|---|---|---|---|---|
| LCP (Largest Contentful Paint) | How soon does the main content appear? | 2.5 s or less | up to 4 s | over 4 s |
| INP (Interaction to Next Paint) | How quickly does the page respond when I use it? | 200 ms or less | up to 500 ms | over 500 ms |
| CLS (Cumulative Layout Shift) | Does the page stay still while I read? | 0.1 or less | up to 0.25 | over 0.25 |
- HTML Code
- Breakdown Lab
- Shift Calculator
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Bread Bin</title>
<!-- LCP: find the important font early -->
<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="/site.css">
<!-- INP and LCP: scripts do not block, and cost less -->
<script src="/js/app.js" defer></script>
</head>
<body>
<!-- LCP and CLS: the main image is early, sized, and not lazy -->
<img src="/img/hero-1200.webp"
srcset="/img/hero-800.webp 800w, /img/hero-1200.webp 1200w"
sizes="100vw"
alt="A golden loaf on a wooden board"
width="1200" height="600" fetchpriority="high">
<!-- CLS: reserve the space an ad will fill -->
<div style="min-height: 250px"></div>
</body>
Largest Contentful Paint (LCP): 3000 ms. Needs improvement (good is 2500 ms or less, poor is over 4000 ms)
Biggest part: Resource load delay (1000 ms). Help the browser find the main image early: put it in an img tag, do not lazy-load it, add fetchpriority, or preload it.
The thresholds are the published ones at the time of writing. The sliders are for learning, not measuring. Real pages show these parts in DevTools and in tools such as PageSpeed Insights.
- Impact fraction: 1 (how much of the screen was affected)
- Distance fraction: 0.375 (how far, compared with the screen)
- This shift scores: 1 x 0.375 = 0.375
Poor (good is 0.1 or less, poor is over 0.25)
This follows the published formula for a single shift on a phone-sized screen (400 by 800 px) with content that spans the full width. The real CLS for a page also adds up several shifts in a time window, so use it to understand the idea, not to predict your score.
LCP: How Soon the Main Content Appearsβ
LCP measures the time from the start of loading to when the largest visible piece of content in the first screen is painted. The browser keeps updating its choice as the page loads, and the final candidate is the one that counts.
What can be the LCP element:
- An
imgelement, or the poster image of a video - An image set with
background-imagein CSS - A block of text, such as a heading or paragraph
LCP is made of four parts, and the lab above lets you change each:
- Time to first byte. How long the server takes to start sending the HTML.
- Resource load delay. How long before the browser starts loading the main image (it must find it first).
- Resource load duration. How long the image takes to download.
- Element render delay. The gap between the file arriving and it being painted, often caused by render-blocking CSS or scripts.
Most slow LCPs are dominated by one part. Find the biggest, and fix that first.
| If the biggest part is... | Try... | Lesson |
|---|---|---|
| Time to first byte | Faster server, CDN, caching | Server-side |
| Resource load delay | Image in HTML, no lazy loading, fetchpriority, preload | Preload, Lazy Loading |
| Resource load duration | Smaller file, right size, modern format | Responsive Images |
| Element render delay | Less render-blocking CSS and scripts | Critical Resources, Defer |
INP: How Quickly the Page Respondsβ
INP measures how long it takes, after a visitor clicks, taps, or presses a key, for the page to show the result. Scrolling and hovering do not count. The browser looks at the interactions during the visit and reports a value close to the slowest one (for busy pages it ignores a few extreme outliers).
An interaction has three parts:
- Input delay. The click happens, but the main thread is busy with something else, so it waits.
- Processing time. Your event handlers run.
- Presentation delay. The browser works out the new look and paints it.
Unlike LCP, INP depends heavily on JavaScript. Long tasks, heavy third-party scripts, and slow handlers all raise it. The HTML-level habits that help are the ones from Script Loading: send less JavaScript, use defer and async, split heavy work, and load non-essential scripts late. In the lab's INP view, try making the input delay large. That is what a page busy running a big script feels like.
INP replaced an older metric called First Input Delay (FID) as a Core Web Vital. If you read older articles that mention FID, the advice about busy main threads still applies, but INP looks at the whole visit, not just the first click.
CLS: Whether the Page Stays Stillβ
CLS measures unexpected movement. You are reading, an image loads above, and the text jumps down. Or you go to tap a button, an ad appears, and you tap the wrong thing.
Each shift is scored with a simple formula:
score = impact fraction x distance fraction
- Impact fraction: how much of the screen the moving content touched (before and after).
- Distance fraction: how far it moved, compared with the largest screen dimension.
Open the Shift Calculator tab and try the presets. A large image with no reserved height that pushes a whole screen of text down 300 px scores far above 0.25. A small banner nudging content 60 px scores much lower. A shift of zero scores nothing.
The usual causes, and their cures:
| Cause | Cure |
|---|---|
Images with no width and height | Always give both |
| Ads, embeds, and iframes with no reserved space | Set a size or a min-height (or aspect-ratio) |
| A late web font that changes the text size | font-display, preload the font, and choose a similar fallback |
| Banners or messages inserted above content | Reserve their space, or add them below, or overlay them |
Animations that change top, left, width, or height | Animate transform and opacity instead |
Shifts that happen right after a click or tap (within about half a second) are treated as expected, and are not counted. A menu that opens when you tap its button is fine. A page that jumps while you are just reading is not.
Lab Data and Field Dataβ
You will meet two kinds of numbers:
- Lab data comes from a test you run: Lighthouse, WebPageTest, DevTools. It is repeatable and good for finding and fixing problems, but it is one device, one connection, and no real interaction.
- Field data comes from real visitors, on their devices and networks. It is what shows how the page really performs, and it is what the search engine report in your site tools uses. Chrome collects it for many sites in a public data set, shown in PageSpeed Insights and Search Console.
Field results are usually judged at the 75th percentile: a page "passes" a vital if at least three out of four visits are good. That is deliberately strict. It means the slower quarter of your visitors matter, so a fast lab test on a fast laptop is not enough.
Not every page has field data, because small sites may not have enough visits. In that case use lab data, and treat it as a guide. Lab tools also report a measure called Total Blocking Time (TBT), which is often used as a stand-in for INP in the lab, since INP needs a real person interacting.
Measure Them Yourselfβ
In the tools: run PageSpeed Insights (lab and field together), open the Core Web Vitals report in Search Console, and record a trace in the DevTools Performance panel.
In the browser console, you can watch the raw events. Here is a small snippet to see the LCP candidates:
new PerformanceObserver(function (list) {
const entries = list.getEntries();
const last = entries[entries.length - 1];
console.log("LCP candidate:", Math.round(last.startTime), "ms", last.element);
}).observe({ type: "largest-contentful-paint", buffered: true });
And a simple view of layout shifts:
let total = 0;
new PerformanceObserver(function (list) {
list.getEntries().forEach(function (entry) {
if (!entry.hadRecentInput) total += entry.value;
});
console.log("Shifts so far:", total.toFixed(3));
}).observe({ type: "layout-shift", buffered: true });
That sum is a simplification, because the official CLS groups shifts into time windows and reports the worst window, but it is good for spotting what moves.
From real visitors, you can collect the vitals with Google's small open-source web-vitals library, which handles the details for you:
import { onLCP, onINP, onCLS } from "web-vitals";
function send(metric) {
navigator.sendBeacon("/vitals", JSON.stringify({ name: metric.name, value: metric.value }));
}
onLCP(send);
onINP(send);
onCLS(send);
Install it with your package manager and pin the version, and check its documentation for the current API, since details can change.
How This Section Moves the Numbersβ
| Lesson | Mainly helps |
|---|---|
| HTML Performance Basics | All three |
| Resource Hints, Preload | LCP |
| Prefetch | Navigation speed to the next page |
| DNS Prefetch, Preconnect | LCP, when third-party hosts are involved |
| Lazy Loading | LCP (by not lazy-loading the main image), data use |
| Script Loading, Defer, Async | INP and LCP |
| Responsive Images | LCP, and CLS (with width and height) |
| Critical Resources | LCP |
Best Practicesβ
- Measure first, in the lab and, where you can, in the field.
- Find the biggest part of each slow metric, and fix that.
- Make the main image early, sized, and not lazy.
- Keep the main thread free: less JavaScript, deferred, and split.
- Reserve space for images, embeds, ads, and late messages.
- Test on a modest phone and a slow connection.
- Change one thing at a time, and measure again.
- Watch field data over time, because releases can quietly undo your gains.
Quick Checklistβ
- The LCP element is known for each key page
- The biggest part of LCP has been identified
- The main image is not lazy, and has
widthandheight - Scripts use
deferorasync, and there are no long tasks on load - Every image, ad, and embed has reserved space
- Animations use
transformandopacity - Lab and field data have both been checked
- Results are rechecked after each release
Security and Privacy Notesβ
- Collecting vitals is collecting data. Real user monitoring records things about your visitors' devices, connections, and pages. Collect the least you need, keep it anonymous where you can, and say what you collect.
- Do not send private information with a metric. Page addresses can contain tokens, search terms, or personal details. Strip them before you send anything.
- Check consent rules. Depending on where your visitors are and what you collect, you may need consent first. This is not legal advice, so check the rules that apply to you.
- A third-party monitoring script is a script. It runs with the power of your page and adds to your page weight. Load it with
async, from a provider you trust. - Public field data is aggregated. The public data sets show combined results and not individual visits, but your own collected data may identify people if you are careless.
Global Audience Notesβ
- Your visitors are not all in one place. Networks, phones, and distance differ widely between countries, so a page that passes for one market can fail for another. Look at field data by country and device where your tools allow it.
- The 75th percentile is the slower quarter. For many audiences, that quarter is on a modest phone and a slow connection, so test there on purpose.
- A CDN, smaller images, and less JavaScript help the visitors with the most to gain.
- Fonts for some scripts are large, and late font swaps can cause shifts. Reserve space and use system fonts or subsets where they fit.
- Do not chase a single score. A perfect lab number means little if real visitors in your main market still wait.
Common Mistakes to Avoidβ
- Optimising for a lab score and ignoring real visitors.
- Testing only on a fast machine.
- Lazy-loading the LCP image.
- Images without
widthandheight. - Heavy third-party scripts on the first load.
- Ads and embeds with no reserved space.
- Animating layout properties instead of
transform. - Fixing the wrong part, such as shrinking an image when the real delay is finding it.
- Changing many things at once, so you cannot tell what helped.
- Collecting more visitor data than you need.
Practice Timeβ
- In the Breakdown Lab, use the LCP view. Which part is the biggest? What does the lab suggest?
- Lower that part until the total is "Good". How far did you have to go?
- Switch to INP, and raise the input delay. What kind of page does that feel like?
- In the Shift Calculator, try each preset. Which one is worst? Which is acceptable?
- Make the shift distance zero. What happens to the score?
- Run PageSpeed Insights on a page you built. What is the LCP element?
- Paste the LCP snippet into the Console, and compare its result with PageSpeed Insights.
- Bonus: pick one lesson from this section, apply it to a page, and measure LCP, INP, and CLS before and after.
Quick Recapβ
Click a question to check your answer.
1. What do the three Core Web Vitals measure?
LCP measures how soon the main content appears, INP measures how quickly the page responds to interaction, and CLS measures how much the layout jumps.
2. What are the four parts of LCP?
Time to first byte, resource load delay, resource load duration, and element render delay. Fix the biggest one first.
3. What makes up INP?
Input delay, processing time, and presentation delay. JavaScript that keeps the main thread busy is the most common cause of a poor INP.
4. How is a layout shift scored?
Impact fraction times distance fraction. A bigger area moving a longer distance scores worse. A shift of zero scores nothing.
5. What is the difference between lab and field data?
Lab data comes from a test you run, and is good for finding problems. Field data comes from real visitors and shows what they really experience, usually judged at the 75th percentile.
6. Name three HTML habits that help the vitals.
Give images width and height, never lazy-load the main image, and use defer or async for scripts. Reserving space for ads and embeds also helps.
Key Takeawaysβ
- The three vitals ask three questions: how soon, how responsive, and how steady.
- Each is made of parts. Find the biggest, and fix that first.
- LCP is helped by finding the main image early and keeping CSS and scripts out of the way.
- INP is helped by sending less JavaScript and keeping the main thread free.
- CLS is helped by reserving space for everything that loads late.
- Use lab data to fix, and field data to confirm. Judge by the slower quarter of your visitors.
- Collect only the data you need, and respect consent.
You have now finished the Performance section. Return to the Performance overview to review the whole path, or apply one lesson at a time to a real page and measure what changes.