Core Web Vitals: measure and improve LCP, INP, and CLS

See how fast your website is for real visitors, then fix the slowest metric first.

app/providers.tsx
import { DatabuddyProvider } from "@databuddy/sdk/react";

<DatabuddyProvider clientId="YOUR_WEBSITE_ID" autocapture={{ webVitals: true }} />;

The Web Vitals page breaks each metric down by page, device, browser and location, with percentiles from p50 to p99. It also collects FCP, TTFB and FPS, which help diagnose but aren't Core Web Vitals.

  1. Field data shows a slow page
  2. Reproduce in a lab tool
  3. Fix
  4. Compare the next period

Read the scores

MetricMeasuresGoodNeeds improvementPoor
LCPWhen the largest visible content appears≤ 2.5 s2.5 to 4 s> 4 s
INPHow fast the page responds to clicks, taps and keys≤ 200 ms200 to 500 ms> 500 ms
CLSUnexpected layout shifts≤ 0.10.1 to 0.25> 0.25

Judge the 75th percentile, separately for mobile and desktop; a fast average can hide many slow visits. See Google's Web Vitals guidance.

In single-page apps, browsers measure page changes differently:

BrowserPage changes inside your appTTFB
Chrome, Edge and other Chromium browsersEach gets its own LCP, FCP, CLS and INP, for the page on screenOnly on loads from your server
Safari, FirefoxOnly the first load is measured; CLS and INP keep adding up across page changesFirst load only

Compare a page's numbers within one browser family, not across them.

Fix a slow LCP

index.html
<img
  src="/product-preview.webp"
  alt="Product dashboard showing traffic and conversions"
  width="1200"
  height="800"
  fetchpriority="high"
/>

Put the main image in the initial HTML, size and compress it for each viewport, and don't lazy-load it. Give only that image high priority. Use a performance trace to find slow responses and render-blocking work. See Optimize LCP.

Fix a slow INP

Reproduce the slow interaction itself, not just page load. Do less in event handlers, break up long tasks, and load optional features when they're needed. An async script still costs time when it runs. See Optimize INP.

Fix layout shifts

Set dimensions or an aspect ratio on images, video and embeds. Reserve space for ads and content that loads later, and don't insert content above what someone is reading. CLS counts the largest burst of shifts, with gaps under a second, lasting at most five seconds. See Google's CLS definition.

To log metrics while debugging, use the web-vitals library. Databuddy already collects them, so don't send them twice:

debug-vitals.js
import { onCLS, onINP, onLCP } from "web-vitals";

const log = ({ name, value }) => console.log(name, value);
onCLS(log);
onINP(log);
onLCP(log);

Check that a fix worked

Compare equal periods and the same device group before and after the change, using the previous-period view. Traffic mix and content changes can move numbers too. Use PageSpeed Insights and Lighthouse CI to catch regressions between releases. Google uses Core Web Vitals in ranking, but good scores don't guarantee rankings (page experience).

How is this guide?