On a high level, this is what the Core Web Vitals are.
-
LCP
Largest Contentful Paint
Is the main content visible?
-
INP
Interaction to Next Paint
Does it respond when I interact?
-
CLS
Cumulative Layout Shift
Does it stay intact?
a page passes when 75% of real visits are green on all three
Maybe these don’t justify anything practically yet, right? So let’s try to understand them from the fundamentals.
What happens when a page loads?
Say I open my own site, mariappan.netlify.app. Before anything shows up, the request goes through five stages.
What gets fetched first?
The HTML document is always the first thing fetched. It’s parsed as it streams in, so content near the top can appear early, before the whole file has arrived.
How does the browser find everything else?
As the parser reads the HTML, it finds other files (stylesheets, images, scripts) and fetches them. Some of those files point to more files. That’s the discovery chain, and the Initiator tab draws it.
Each hop waits for the file before it. The deeper a file sits, the later it can start.
What happens inside one request?
Open the Timing tab on the document, and every stage gets a number.
Now reload the page. A few stages disappear, because the browser reuses the connection it already has. Open the page fresh (a new Incognito window is the surest way), and they all come back.
So, what’s TTFB?
Time to first byte. Everything before content download counts towards it: the queue, the connection, and the wait for the server.
New tab · fresh connection939 ms
Reload · reused connection194 ms
no TCP, no TLS: the line was already open
- TTFB ≈ total − content download. On the fresh run, 939.19 − 2.98 ≈ 936 ms.
- No DNS or connection rows? The connection was reused. Test fresh to see the real cost.
- “Waiting for server response” alone isn’t TTFB. It’s only the server’s share.
Noticed the three labels at the bottom?
They sit at the bottom of the Network panel, and two of them also draw a line across the waterfall.
-
blue line · 2.93 s
DOMContentLoadedHTML fully parsed, and normal and defer scripts have run. Doesn’t wait for images or fonts.
-
red line · ~3.3 s
LoadEverything from the initial load is in: CSS, fonts, scripts, images (not lazy ones).
-
no line · 4.65 s
FinishThe last network request finished. Lazy images and analytics keep pushing it.
none of these is a paint time. painting isn’t in the Network panel at all
How do pixels get painted?
Downloaded ≠ painted.
A file can be fully downloaded and still not be on screen. That gap is the render delay, and it’s where a lot of slow pages hide.
What happens when the parser finds CSS?
It keeps reading. Only the painting waits, because every element needs to know what the CSS does to it.
And when it finds a script?
It stops right there, until the script downloads and runs. Why do you think so?
Think for a second, then tap
Because a script can change the page itself. It can add, remove or rewrite the very elements the parser is about to read, so the parser has to wait and see.
Parser finds <link rel="stylesheet">
- Readerkeeps reading
- Painterwaits for the CSS
Parser finds <script src="app.js">
- Readerstops at the script
- Painterpaints what’s above
That’s why people care so much about defer, async and where a script sits.
Normal, async or defer?
Normal<script>
blocksbest for tiny scripts that must run first, like the theme
Async<script async>
pausesbest for analytics, ads, chat widgets
Defer<script defer>
never blocksbest for your app code
Module scripts (type="module", what Vite and Astro output) behave like defer by default.
Try it: watch it paint
Four experiments, one page. Press play and watch what shows up, and when.
index.html
<head>
</head>
<body>
<h1>Top of the page</h1>
<p>I am above the script.</p>
<p>I am below the script.</p>
<img src="photo.jpg" alt="">
</body>
<head>
<link rel="stylesheet" href="slow.css">3 s
</head>
<body>
<h1>Top of the page</h1>
<p>I am above the script.</p>
<p>I am below the script.</p>
<img src="photo.jpg" alt="">
</body>
<head>
</head>
<body>
<h1>Top of the page</h1>
<p>I am above the script.</p>
<script src="slow.js"></script>3 s
<p>I am below the script.</p>
<img src="photo.jpg" alt="">
</body>
<head>
</head>
<body>
<h1>Top of the page</h1>
<p>I am above the script.</p>
<script defer src="slow.js"></script>
<p>I am below the script.</p>
<img src="photo.jpg" alt="">
</body>
- ParserBlocked by the script
- PainterPainting
- ImageDownloaded, not painted
The parser stops at the script for 3 s, so only the text above it paints. The image finished downloading at 1.5 s, but it can’t paint until the parser reaches it. That gap is render delay.
LCP: when the biggest thing paints
Navigation start → the biggest visible thing is painted.
Only what’s visible in the viewport counts.
Which element is the LCP?
On desktop, it’s my portrait. On a phone, the portrait drops below the fold and a paragraph takes over. The Performance tab’s Live metrics shows which.
What is the LCP number made of?
The interesting part: hover the value, and DevTools splits it into four parts we’ve already met.
- 1 Time to first byte Until the HTML’s first byte arrives. ↩ the Timing tab
- 2 Resource load delay From then until the LCP file starts downloading. ↩ the discovery chain
- 3 Resource load duration Downloading the file itself. ↩ the waterfall
- 4 Element render delay Downloaded, but not painted yet. ↩ downloaded ≠ painted
Desktop · the portrait2.47 s
Mobile · the paragraph1.14 s
text has no file to fetch: only TTFB and render delay
The fix depends on the biggest part, and the biggest part depends on the device.
Are live metrics enough?
They’re a quick look. The proper audit is record and reload.
- 1Throttle network and CPU
- 2Record and reload
- 3Read the insights
- LCP breakdown
- Render-blocking requests
- Ways to improve
- Ask AI, added recently :)
What if I click early?
LCP stops at the first click, tap or key press. I found out by accident: I clicked a social link early, and LCP froze at a better number than the page deserved.
So what was wrong on my portfolio?
- missing
srcsetPhones downloaded desktop-sized portraits.
- there, but
fetchpriority="high"Only speeds the download. Can’t fix discovery or render delay.
- there, but
loading="lazy"Skips only far-off images. My stacked carousel was all “in view”.
Can I read it in code?
Yes, through PerformanceObserver.
new PerformanceObserver((list) => { const entry = list.getEntries().at(-1); // the last candidate wins console.log(Math.round(entry.startTime), entry.element);}).observe({ type: 'largest-contentful-paint', buffered: true });
CLS: when the page moves on its own
How much visible content moves without the user causing it.
Is it one shift or many?
Many. Shifts come in bursts (session windows), and CLS is the worst burst, not the total.
CLS = 0.18 the worst burst
not 0.24 every shift added up
a burst ends after 1 s of calm, or at 5 s
How is a shift scored?
Impact fraction × distance fraction: how much of the screen moved, times how far.
impact fraction0.75how much of the screen the move touched
distance fraction0.25how far it moved, as a share of the screen
layout shift score≈ 0.19
So CLS has no unit, just a score. Here’s my portfolio’s.
Two shifts, 0.0003 and 0.0047, in one burst. Together 0.005, shown rounded as 0.01.
What usually causes shifts?
Usually something arrives late, or grows, and pushes everything under it.
- Images and embeds without a size Set width and height (or aspect-ratio), so the space is held before it loads.
- Content injected above Banners, ads, cookie bars: reserve the slot, or overlay it instead of pushing.
- Web fonts swapping The fallback and the web font take different space. Match the fallback’s metrics.
- Animating top or height Animate transform instead. Transform moves don’t count as shifts.
So the fix is always the same: hold the space up front.
What about a Load more button?
Results that arrive 1 s after the click are outside the 500 ms window, so they count. The fix: a skeleton of the right size, straight away.
With a skeleton
Waiting for a click
INP: the main thread and one busy cashier
You must be feeling the weight of all these terms by now. So let’s keep this one light. Picture a café with a single cashier.
-
1Wait
Input delay
The cashier is busy with someone else. You wait to even start.
-
2Work
Processing duration
They take your order, and making it takes time.
-
3Show
Presentation delay
It’s ready, but handing it over takes a moment. That’s the paint.
INP = wait + work + show, from your tap to the next frame on screen
That cashier is the main thread. It runs all the JavaScript on the page, one job at a time, because JavaScript is single-threaded.
What if I tap while it’s busy?
Your tap doesn’t interrupt. It joins a queue, and the event loop picks it up when the thread is free. Try it.
tap while the thread is busy, then while it’s free
Main thread
Your tap’s timing shows up here.
The event loop deserves a post of its own. For the full picture, watch this talk on it.
How did my portfolio do?
Live metrics lists every interaction with its three parts. Flipping the portrait card was my slowest, so it set the INP.
Lab vs field: which number counts?
Everything so far was lab data: one load, my machine, my network. Great for debugging.
The real pass mark comes from real visitors, at the 75th percentile: 75% of visits must be good, on all three.
20 real visits, sorted by LCP
So how do we measure real visits?
Lab
- One simulated load
- DevTools, Lighthouse
- Finds the why
- No real visitor, so no real INP
Fieldthe score
- Real visitors, real devices
- CrUX, or your own RUM
- Decides pass or fail
- Shows what, not why
For your own real-user monitoring (RUM), there’s the web-vitals library.
import { onLCP, onINP, onCLS } from 'web-vitals';// each fires with the metric's value, rating and attributiononLCP(sendToAnalytics);onINP(sendToAnalytics);onCLS(sendToAnalytics);
- Lab vs field data, web.dev
- PageSpeed Insights
- Chrome UX Report (CrUX)
- Search Console’s Core Web Vitals report
- web-vitals library
Why does all this matter?
Because they’re how a page feels to the person using it: does it show up, does it answer, does it stay still.
That’s the way I learned it: DevTools open, on my own site, one metric at a time. Pick a page you own and try the same.