Core Web Vitals & Lighthouse
Measure LCP, INP and CLS and fix the biggest regressions.
By Invicly Tech, , in Frontend with React & Next.js. About 12 minutes to read.
In short
Core Web Vitals are three user-centred metrics: loading speed, responsiveness and visual stability. Lighthouse and real-user data show which one is weakest so you fix the biggest problem first.
Explained simply
People leave slow websites. Google measures how a page feels to real visitors with three numbers called Core Web Vitals. They answer three simple questions: does the main content show up quickly, does the page react quickly when I tap, and does the page stay still while it loads?
LCP measures the first question: how long until the biggest image or block of text appears. INP measures the second: how long after a click or key press until the screen changes. CLS measures the third: how much things jump around, like a button that moves just as you try to tap it.
You can measure these two ways. A lab test, such as Lighthouse in Chrome, loads your page on a simulated slow phone and gives you a detailed report. Field data comes from real visitors on their own phones and networks. The lab helps you find the cause; the field tells you if real people are happy.
Fixing performance works best one problem at a time. Find which metric is worst, find the element or script that causes it, fix that, and measure again.
Press Play on a diagram to walk through it one step at a time.
- Largest Contentful Paint
- Loading: when main content shows
- Good: 2.5 s or less
- Fix: optimise hero image, server time
- Interaction to Next Paint
- Responsiveness to clicks and keys
- Good: 200 ms or less
- Fix: break up long JavaScript tasks
- Cumulative Layout Shift
- Visual stability while loading
- Good: 0.1 or less
- Fix: set image sizes, reserve space
- One simulated device and network
- Repeatable, run any time
- Detailed diagnostics
- Cannot measure INP (uses TBT)
- Real users, devices and networks
- 75th percentile over 28 days in CrUX
- What Google uses for ranking signals
- Tells you that it is slow, not why
In depth
How the thresholds are judged
Each metric has three bands. LCP is good at 2.5 seconds or less and poor above 4 seconds. INP is good at 200 milliseconds or less and poor above 500 ms. CLS is good at 0.1 or less and poor above 0.25. Anything between is "needs improvement".
A page passes when the 75th percentile of real visits is in the good band, for each metric separately, and mobile and desktop are judged separately too. The 75th percentile means three out of four visits must be at least that fast, so a fast laptop on office Wi-Fi does not hide slow phones. Google's public field data, the Chrome UX Report (CrUX), uses a rolling 28-day window, so a fix takes weeks to show fully there. INP replaced the older First Input Delay (FID) metric in March 2024; FID measured only the delay before the first interaction, while INP looks at nearly all interactions on the page.
- Good: 2.5 s or less
- Poor: over 4 s
- Measured once per page load
- Good: 200 ms or less
- Poor: over 500 ms
- Close to the slowest interaction
- Good: 0.1 or less
- Poor: over 0.25
- Largest burst of layout shifts
Running Lighthouse and reading the report
Open Chrome DevTools, choose the Lighthouse panel, pick Mobile and Performance, and analyse the page in an incognito window so extensions do not interfere. By default Lighthouse simulates a mid-range phone on a slow 4G connection, which is why scores are lower than your own experience. PageSpeed Insights (pagespeed.web.dev) runs the same audit on Google's servers and also shows CrUX field data for your URL when enough visitors exist.
The performance score combines five lab metrics: Total Blocking Time (30 percent), LCP (25), CLS (25), First Contentful Paint (10) and Speed Index (10). A lab test has no real user clicking, so it cannot measure INP; Total Blocking Time, the time long JavaScript tasks block the main thread, stands in for it. Scores vary a few points between runs, so run it several times. Below the score, the Diagnostics section names the LCP element and the scripts and images causing problems.
- npx lighthouse https://example.com --view runs it from the terminal
- Test a production build, never the dev server
- DevTools Performance panel shows live LCP, INP and CLS as you interact
Finding and fixing the LCP bottleneck
LCP can be split into four parts: Time to First Byte (the server's response), resource load delay (how long before the browser even starts downloading the LCP image), resource load duration (the download itself), and element render delay (time until it is painted). Lighthouse and the DevTools Performance panel show this breakdown, so you fix the biggest part instead of guessing.
Common fixes match each part. Slow TTFB: cache pages, render static pages at build time, or use a CDN. Long load delay: the image is discovered late, often because it is a CSS background or added by JavaScript, or because it is lazy loaded; put it in the HTML, give it the fetchpriority="high" attribute, and never lazy load the hero. Long download: serve a correctly sized modern format such as WebP or AVIF; next/image does this, and on the hero you can pass loading="eager" and fetchPriority="high". Render delay: render-blocking CSS, web fonts or client-side rendering of the main content.
- Step 1TTFB
Server sends the first byte of HTML
- Step 2Load delay
Browser discovers the hero image
- Step 3Load duration
Image bytes download
- Step 4Render delay
CSS, fonts, JS finish; image painted
Improving INP: keeping the main thread free
An interaction has three phases: input delay (the browser is busy with other work when you tap), processing time (your event handlers run), and presentation delay (the browser recalculates layout and paints the next frame). JavaScript runs on a single main thread, so any task longer than 50 ms, called a long task, can delay all three.
Fixes: ship less JavaScript, for example by keeping components as Server Components in Next.js and loading heavy widgets with dynamic import only when needed. Break long work into chunks and yield to the browser between them, with await scheduler.yield() where supported or a setTimeout of 0 as a fallback. In React, wrap non-urgent updates such as filtering a big list in startTransition (or useTransition), so typing stays responsive. Debounce expensive handlers, avoid huge DOM trees, and give immediate visual feedback, such as a pressed state, before the slow work starts.
Removing layout shifts
A layout shift happens when a visible element moves without the user causing it. Each shift gets a score from how much of the screen moved and how far. CLS is not a simple total: shifts are grouped into session windows (bursts of shifts less than 1 second apart, up to 5 seconds long) and the worst window counts. Shifts within 500 ms after a click or key press are excluded, because the user expects the page to react.
The usual causes and fixes: images and videos without size, so give them width and height attributes or CSS aspect-ratio and the browser reserves the space. Ads, embeds and cookie banners injected above content, so reserve a fixed-size slot or show banners as an overlay. Web fonts that swap in with different sizes; next/font self-hosts fonts and adjusts the fallback font's metrics to reduce the jump. Animate with transform and opacity, which never cause layout shifts, instead of top, left, width or height.
- Use width and height on every img, or next/image which requires them
- Skeleton placeholders the same size as the final content
- DevTools Performance panel highlights each layout shift
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Explain LCP, INP and CLS~45m
- 2Run a Lighthouse audit~45m
- 3Fix the largest LCP issue~45m
- 4Remove layout shifts~45m
Key points
- Lab data from Lighthouse is for debugging; field data shows real users.
- The LCP element is usually a hero image or large heading.
- Long main-thread tasks hurt INP; ship less JavaScript and split work.
- Give images and embeds dimensions so content does not jump.
Key terms
Tap a card to flip it. 0/5 known
Examples
Fixing a slow hero image in Next.js
Lighthouse says LCP is 4.8 s on mobile and the LCP element is the hero image, with a long resource load delay. Step 1: the image was a CSS background, discovered only after the CSS loaded. Step 2: switch to next/image in the HTML. Step 3: load it eagerly with high fetch priority, and set sizes so phones download a small version. Step 4: rerun Lighthouse; load delay drops and LCP moves under 2.5 s.
import Image from 'next/image';
import hero from './hero.jpg'; // static import gives width, height and blur data
export function Hero() {
return (
<Image
src={hero}
alt="Runners at sunrise on the beach"
loading="eager" // never lazy load the LCP image
fetchPriority="high" // download it before other images
sizes="100vw" // browser picks a size that fits the screen
placeholder="blur"
style={{ width: '100%', height: 'auto' }}
/>
);
}Sending real-user Web Vitals to your analytics
Lab scores looked fine, but you want to see real phones. Step 1: Next.js provides useReportWebVitals, a hook that receives each metric as the browser measures it. Step 2: put it in a small client component rendered from the root layout. Step 3: send name, value and rating with navigator.sendBeacon, which still delivers when the page is closing. Step 4: in your analytics, chart the 75th percentile per page.
'use client';
import { useReportWebVitals } from 'next/web-vitals';
export function WebVitals() {
useReportWebVitals((metric) => {
// metric.name is 'LCP', 'INP', 'CLS', 'FCP' or 'TTFB'
const body = JSON.stringify({ name: metric.name, value: metric.value, rating: metric.rating, page: location.pathname });
navigator.sendBeacon('/api/vitals', body);
});
return null;
}
// app/layout.tsx: render <WebVitals /> inside <body>Quick reference
- Good: LCP 2.5 s or less, INP 200 ms or less, CLS 0.1 or less (75th percentile)
- Lighthouse = lab (simulated slow phone); CrUX and RUM = field (real users)
- Never lazy load the LCP image; give it fetchpriority="high" (fetchPriority in JSX)
- LCP parts: TTFB, load delay, load duration, render delay
- Long task = over 50 ms on the main thread; split work and yield
- startTransition for non-urgent React updates keeps input responsive
- Set width and height (or aspect-ratio) on images and embeds to prevent CLS
- Animate transform and opacity, not top, left, width or height
Common mistakes
- Optimising for a Lighthouse score on a fast laptop instead of real devices.
- Lazy loading the hero image, which delays LCP.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Run a mobile Lighthouse audit on a production build of your app and write down the LCP element, LCP time, TBT and CLS.
- Exercise 2medium
A product card image causes a CLS of 0.18. The img has no size and loads from a CMS URL. Fix it without changing the design.
- Exercise 3hard
A click handler processes 5,000 items in one loop and blocks the main thread for 400 ms. Rewrite it to yield to the browser every 500 items.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Do Core Web Vitals affect Google rankings?
- Yes, they are part of Google's page experience signals, but content relevance matters far more. Treat them mainly as a user experience goal: faster pages keep more visitors.
- Why is my Lighthouse score different every time?
- Network, CPU load and server response time vary between runs. Run it several times, use the median, and compare before and after changes under the same conditions.
- What replaced First Input Delay?
- Interaction to Next Paint (INP) replaced FID as a Core Web Vital in March 2024. INP measures the full time from interaction to the next frame, across almost all interactions, not just the first.
- Is a Lighthouse score of 100 necessary?
- No. Aim for the good thresholds in field data on mobile. A score of 90 or more on a mid-range phone simulation is a strong result for most apps.