How to Improve Your Core Web Vitals: Fix LCP, INP and CLS in the Right Order

The field-data-first method: read your real-user numbers, install attribution tracking, split LCP into its four subparts, break up the long tasks behind slow INP, stop layout shifts at the source, and lock the gains in with Lighthouse CI so the next release doesn't undo them.

By · 20.11.2026

Most Core Web Vitals advice is a checklist: compress images, defer JavaScript, add dimensions. Teams work through it, the Lighthouse score goes green, and a month later Search Console still shows the same URLs as "Poor". The checklist wasn't wrong. It was aimed at the wrong thing. Google ranks on what real visitors experience, measured in Chrome over 28 days. Your lab score is only a guess at that.

This guide fixes Core Web Vitals in the order that actually moves the field numbers. You read what real users see, attach attribution so every bad score names its cause, and then fix LCP, INP and CLS one subpart at a time. Each step ends with a way to check that it worked. The examples cover plain HTML and Next.js, with notes for WordPress and Shopify. If you're in the middle of a redesign, read our relaunch playbook alongside this one, because relaunches are where most performance regressions start.

Copy & paste

Start here: plan it with AI

Copy this prompt into any LLM or coding agent (Claude, ChatGPT, Cursor …) to apply this guide to your own project.

Guide: https://blackcard.dev/guides/how-to-improve-your-core-web-vitals
Markdown version (fetch this for the full method): https://blackcard.dev/guides/how-to-improve-your-core-web-vitals.md

I want to improve my website's Core Web Vitals, following the guide "How to Improve Your Core Web Vitals" from blackcard.dev.

The method: start from FIELD data (Search Console Core Web Vitals report, PageSpeed Insights field section, CrUX API), not Lighthouse scores; group failing URLs by page template; install real-user monitoring with the web-vitals attribution build; split LCP into its four subparts (time to first byte, resource load delay, resource load duration, element render delay) and fix the biggest one first; fix INP by finding the slow interaction and its long script, then yielding to the main thread; fix CLS at the source (reserved space, font metric overrides, no injected content above existing content); lock the gains in with Lighthouse CI budgets; validate in Search Console over 28 days.

Interview me one question at a time:
1. What is the site's URL and what is it built with (Next.js, WordPress, Shopify, other)? Where is it hosted?
2. What does the Search Console Core Web Vitals report show for mobile and desktop: which metric fails, and on how many URLs?
3. Which page templates matter most for revenue or leads (home, product, category, article, landing pages)?
4. Which third-party scripts load on every page (tag manager, analytics, chat, A/B testing, cookie banner, ads)?
5. Who can deploy code changes, and is there a CI pipeline?

Then produce: a prioritized list of failing templates, my likely root cause per metric based on my stack, and a step-by-step fix plan in the order of the guide, with how I verify each step.

What Core Web Vitals are in 2026

Core Web Vitals are three metrics Google uses to describe how a page feels to a real visitor:

  • Largest Contentful Paint (LCP) is loading: how long until the biggest image or text block in the viewport has rendered. Good is 2.5 seconds or less, poor is over 4 seconds.
  • Interaction to Next Paint (INP) is responsiveness: across all clicks, taps and key presses during a visit, roughly the slowest time from input to the next frame on screen. Good is 200 milliseconds or less, poor is over 500 ms. INP replaced First Input Delay in March 2024. FID only measured the delay before your code ran. INP measures the whole interaction, which is why so many sites that passed FID fail INP.
  • Cumulative Layout Shift (CLS) is visual stability: how much visible content jumps around unexpectedly. Good is 0.1 or less, poor is over 0.25.

Four details decide whether your work counts:

  1. Google scores the 75th percentile. To pass a metric, 75% of page visits must be "good". Average speed doesn't help you here. You're fixing the slow quarter of your visitors, which usually means mid-range Android phones on mobile networks.
  2. The data comes from the Chrome UX Report (CrUX). It's a rolling 28-day window of real Chrome users who opted in. A fix shipped today shows up in full about four weeks later. Since Safari 26.2 (December 2025), Safari and Firefox can also measure LCP and INP, so your own monitoring sees iPhone users too. Google's public dataset is still Chrome-only.
  3. Mobile and desktop are scored separately. Mobile is almost always worse, and it's the one that matters for most sites.
  4. Pages with too little traffic are grouped. If a single URL doesn't have enough visits, Search Console groups it with similar URLs, or uses the whole origin's data. In practice you fix templates, not individual pages.

How much does it matter? Core Web Vitals are a confirmed part of Google's page experience signals. They work as a tie-breaker between pages of similar relevance, not as a way to outrank better content. The bigger payoff is commercial. Faster LCP and lower INP reliably improve bounce rate and conversion, and a page that jumps while someone reaches for "Buy" loses that sale whether or not Google notices. We cover the conversion side in our ecommerce conversion tips.

There are no new Core Web Vitals in 2026, and Google hasn't changed the thresholds. If you see a blog post saying LCP's "good" limit dropped to 2.0 seconds, check it against Google's own documentation. It still says 2.5.

What you need before you start

  • Access to Google Search Console for the domain (owner or full user), and the property verified for the right protocol and host.
  • Chrome (any current version) with DevTools. Its Performance panel shows live LCP, INP and CLS for your own session, plus field data from CrUX alongside.
  • The ability to deploy code to the site, or a developer who can. Some fixes are configuration changes (caching, image settings), but most of the important ones are template changes.
  • A Google Cloud API key for the CrUX API (free; create it in the Google Cloud console and enable the "Chrome UX Report API").
  • Node.js 20 or later if you follow the monitoring and CI steps. The examples use web-vitals 6.2.3 and @lhci/cli 0.16.1, the current releases as of November 2026.
  • Realistic time: half a day to measure and triage, one to two days to install monitoring and find root causes, then typically 3 to 10 developer days of fixes for a business site or shop, depending on how much third-party JavaScript you carry. After that, 28 days until Google's numbers fully reflect the change.

Step 1: Read the field data and group failures by template

Don't open Lighthouse yet. Start with what Google actually sees.

Search Console. Open Experience → Core Web Vitals. Look at the Mobile report first. Click into each issue row ("LCP issue: longer than 2.5s (mobile)", "INP issue: longer than 200ms", and so on). Each issue lists URL groups with an example URL and the group's 75th-percentile value. Write the groups down in a sheet: issue, example URL, number of URLs, p75 value.

PageSpeed Insights. Paste each example URL into pagespeed.web.dev. The top section, "Discover what your real users are experiencing", is field data. The Lighthouse score below it is a single simulated load. When they disagree, the field data wins. Toggle between "This URL" and "Origin" to see whether the problem is the page or the whole site.

The CrUX API, for repeatable numbers you can track in a script. This call returns the p75 values for one URL on phones:

export CRUX_KEY="your-api-key"

curl -s "https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=$CRUX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.example.com/products/blue-sofa",
    "formFactor": "PHONE",
    "metrics": ["largest_contentful_paint", "interaction_to_next_paint", "cumulative_layout_shift"]
  }' | jq '.record.metrics | map_values(.percentiles.p75)'

Expected output:

{
  "cumulative_layout_shift": "0.18",
  "interaction_to_next_paint": 312,
  "largest_contentful_paint": 3870
}

LCP and INP come back in milliseconds. CLS comes back as a string. Swap "url" for "origin": "https://www.example.com" to get the whole site. If you get a 404 with "chrome ux report data not found", that URL doesn't have enough traffic. Query the origin instead. The companion endpoint records:queryHistoryRecord takes the same body and returns weekly data points, which is how you'll prove the improvement later.

Group by template. Product pages, category pages, blog articles, the home page and landing pages each share one HTML structure, so they share one set of problems. Rank the templates by traffic × how badly they fail × how close they are to revenue. A slow product template beats a slow "About us" page every time. This is the same idea as scoring UX issues by money-flow proximity in our UI/UX audit guide.

Verify: you have a short list (usually two to four templates), each with the failing metric and its p75 value on mobile. That list is your backlog.

Step 2: Install real-user monitoring with attribution

Field data tells you that a template fails. It doesn't tell you why: which element was the LCP, which button caused the slow interaction, which banner shifted the layout. You get that from the web-vitals library's attribution build, running on your own visitors.

Install it:

npm install web-vitals@6.2.3

Create a small reporter. This version batches metrics and sends them once, when the page is hidden, which is the moment the final INP and CLS values are known:

// lib/vitals.js
import { onLCP, onINP, onCLS } from "web-vitals/attribution";

const queue = new Set();

function addToQueue(metric) {
  const a = metric.attribution || {};
  queue.add({
    name: metric.name,            // "LCP" | "INP" | "CLS"
    value: Math.round(metric.name === "CLS" ? metric.value * 1000 : metric.value),
    rating: metric.rating,        // "good" | "needs-improvement" | "poor"
    id: metric.id,
    page: location.pathname,
    template: document.body.dataset.template || "unknown",
    // The "why", per metric:
    lcpTarget: a.target,
    lcpUrl: a.url,
    ttfb: a.timeToFirstByte,
    loadDelay: a.resourceLoadDelay,
    loadDuration: a.resourceLoadDuration,
    renderDelay: a.elementRenderDelay,
    inpTarget: a.interactionTarget,
    inpType: a.interactionType,
    inputDelay: a.inputDelay,
    processing: a.processingDuration,
    presentation: a.presentationDelay,
    longestScript: a.longestScript?.entry?.sourceURL,
    loadState: a.loadState,
    clsTarget: a.largestShiftTarget,
    connection: navigator.connection?.effectiveType,
    deviceMemory: navigator.deviceMemory,
  });
}

function flush() {
  if (queue.size === 0) return;
  const body = JSON.stringify([...queue]);
  // sendBeacon survives the page being closed; fall back to fetch keepalive.
  const sent = navigator.sendBeacon?.("/api/vitals", new Blob([body], { type: "application/json" }));
  if (!sent) fetch("/api/vitals", { method: "POST", body, keepalive: true });
  queue.clear();
}

export function startVitals() {
  onLCP(addToQueue);
  onINP(addToQueue);
  onCLS(addToQueue);
  addEventListener("visibilitychange", () => {
    if (document.visibilityState === "hidden") flush();
  });
}

Two details make the data useful. Set data-template="product" (or "category", "article", and so on) on the body element of each template, so you can group results the same way you grouped them in Step 1. And CLS is multiplied by 1000 so every value is an integer and easy to store.

In Next.js (App Router), load it from a client component in the root layout:

// app/VitalsReporter.tsx
"use client";
import { useEffect } from "react";
import { startVitals } from "@/lib/vitals";

export function VitalsReporter() {
  useEffect(() => {
    startVitals();
  }, []);
  return null;
}
// app/api/vitals/route.ts
import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const rows = await request.json();
  // Start simple: structured logs your host already keeps.
  // Later: insert into Postgres, BigQuery or your analytics tool.
  for (const row of rows) console.log(JSON.stringify({ type: "web-vital", ...row }));
  return new NextResponse(null, { status: 204 });
}

Add <VitalsReporter /> inside the body element in app/layout.tsx. The library uses buffered performance observers, so it doesn't need to load early. It picks up entries that happened before it loaded.

On WordPress or Shopify, or any site where you can't add a route, load the library's IIFE build from a CDN with a classic script tag before the closing body tag, then post to an endpoint you control or to your analytics tool. The library's README has a ready-made Google Analytics 4 example. Sending to GA4 is fine for small sites. Just remember that GA4 sampling and event limits make p75 maths awkward at scale.

Once the rows land in a database, the query that matters is p75 per template and metric. In Postgres:

SELECT template, name,
       percentile_cont(0.75) WITHIN GROUP (ORDER BY value) AS p75,
       count(*) AS samples
FROM web_vitals
WHERE received_at > now() - interval '7 days'
GROUP BY template, name
ORDER BY template, name;

Verify: open the site on your phone, tap around, then switch apps (that hides the page and triggers the flush). Within a minute you should see rows for LCP, CLS and, if you tapped something, INP in your logs, with lcpTarget filled with a CSS selector such as main>section>img.hero. Give it two to three days of traffic before drawing conclusions. A few hundred samples per template is enough to see the pattern.

If you're running consent management: performance metrics without identifiers are often treated differently from tracking, but that's a legal question for your setup. Don't attach user IDs to vitals rows, and ask whoever owns your privacy policy before you ship.

Step 3: Split LCP into its four subparts

Every LCP time breaks down into four consecutive parts. The attribution build reports all four, and the biggest one tells you which fix to make:

  1. Time to First Byte (TTFB), from navigation start until the first byte of HTML arrives. This is the server, the CDN, redirects and the connection.
  2. Resource load delay, from TTFB until the browser starts downloading the LCP image. This is how late the browser discovers the image.
  3. Resource load duration, how long the image download takes. This is file size and the network.
  4. Element render delay, from download complete until the element actually paints. This is render-blocking CSS, JavaScript, fonts, or a hero that waits for client-side code.

For text LCP elements, like a big headline, there's no resource, so the two middle parts are zero and everything is TTFB plus render delay.

Google's guidance for a well-optimized page is roughly 40% TTFB, under 10% load delay, about 40% load duration and under 10% render delay. Compare your p75 breakdown to that. A typical failing product page looks like this: TTFB 900 ms, load delay 1,400 ms, load duration 600 ms, render delay 300 ms, for a total of 3.2 s. The problem there isn't image size, which is what the checklist would have you work on. It's that the browser finds the image 1.4 seconds late.

Reproduce it locally. Open the example URL in Chrome, open DevTools → Performance, set CPU throttling to 4× and the network to "Fast 4G", and record a reload. The LCP by phase section of the Performance insights shows the same four parts, and hovering the LCP marker highlights the element. If your lab breakdown roughly matches the field breakdown, you can iterate locally. If it doesn't (for example, field TTFB is far higher than local), the cause sits in caching, geography or redirects that only real users hit.

Fix the biggest part first, then re-measure. Steps 4 to 6 cover each one.

Step 4: Cut time to first byte

A good TTFB is around 800 ms or less at p75. Above that, it eats your LCP budget before the browser has seen a single tag. The usual causes and fixes:

Serve HTML from a cache, close to the user. Most marketing pages, articles and even product pages can be cached at the CDN for minutes or hours. In Next.js, make the page static with time-based revalidation instead of rendering it on every request:

// app/products/[slug]/page.tsx
export const revalidate = 3600; // regenerate at most once an hour

export async function generateStaticParams() {
  const products = await getTopProducts(200);
  return products.map((p) => ({ slug: p.slug }));
}

For hand-built responses, the header that does the same thing at the CDN is:

Cache-Control: public, s-maxage=3600, stale-while-revalidate=86400

s-maxage lets the CDN cache it for an hour. stale-while-revalidate keeps serving the cached copy while a fresh one is fetched in the background, so no visitor waits for the origin. Check what you actually get with:

curl -sI https://www.example.com/products/blue-sofa | grep -iE "cache-control|age|x-cache|cache-status"

A rising age header or a HIT in the cache status means it's working. A MISS on every request means something is preventing caching. The common culprits are a Set-Cookie header on every response, Cache-Control: private, or personalization in the HTML.

Move personalization out of the HTML. "Hello, Anna" and the cart count make the whole page uncacheable. Render the cacheable shell first and fetch the personal bits from the client afterwards, in a fixed-size slot so they don't cause layout shift.

Kill redirect chains. http://example.com → https://example.com → https://www.example.com → /en/ costs a full round trip per hop, which can be 300 ms or more each on mobile. Link and redirect straight to the final URL, and make sure your ads and email campaigns do too. UTM-tagged campaign links that bounce through a tracking redirect show up as terrible field TTFB for exactly your highest-intent visitors.

Check the origin when the cache misses. If server rendering is slow, profile the data fetching. The classic case is sequential database or API calls that could run in parallel (Promise.all), or an uncached call to a slow third-party API on every render.

Verify: re-run the curl check and a WebPageTest or PageSpeed Insights lab run. TTFB from a nearby test location should be under 200 ms for cached HTML. In your RUM data, p75 ttfb for the template should drop within a day of deploying.

Step 5: Make the LCP image start early and arrive fast

If resource load delay is your biggest part, the browser discovers the image late. If resource load duration is the biggest, the image is too heavy or too far away. Work through these in order.

1. Put the image in the HTML as a real img element. An image set as a CSS background-image, or inserted by JavaScript (a slider library, a client-rendered hero), is invisible to the browser's preload scanner until the CSS or script has run. A plain tag is found the moment the HTML arrives.

2. Never lazy-load the LCP image, and give it high priority. Lazy-loading the hero is the single most common LCP bug we see, often because a plugin or a component library sets loading="lazy" on every image. The correct markup:

<img
  src="/images/hero-1200.avif"
  srcset="/images/hero-640.avif 640w, /images/hero-960.avif 960w, /images/hero-1200.avif 1200w, /images/hero-1600.avif 1600w"
  sizes="(max-width: 768px) 100vw, 1200px"
  width="1200"
  height="675"
  alt="Blue three-seat sofa in a bright living room"
  fetchpriority="high"
  decoding="async"
/>

fetchpriority="high" moves the image to the front of the download queue. Use it on one image per page, the likely LCP element. If you mark five images as high priority, none of them is.

In Next.js 13 to 15, next/image handles this with the priority prop. From Next.js 16, priority is deprecated in favor of preload, and the Next.js docs recommend fetchPriority="high" (or loading="eager") for most cases:

import Image from "next/image";
import hero from "@/public/images/hero.jpg";

// Next.js 16+
<Image src={hero} alt="Blue three-seat sofa" fetchPriority="high" sizes="(max-width: 768px) 100vw, 1200px" />

// Next.js 13–15
<Image src={hero} alt="Blue three-seat sofa" priority sizes="(max-width: 768px) 100vw, 1200px" />

Always pass sizes for responsive images. Without it, next/image (and plain srcset) may send a phone the 1600-pixel version.

3. Preload when the image can't be in the HTML. If the LCP image really must come from CSS or JavaScript, tell the browser about it in the head:

<link rel="preload" as="image" href="/images/hero-1200.avif"
      imagesrcset="/images/hero-640.avif 640w, /images/hero-1200.avif 1200w"
      imagesizes="100vw" fetchpriority="high">

4. Make the file small. Serve AVIF with a WebP or JPEG fallback (most image CDNs and next/image negotiate this automatically from the Accept header). A hero image for phones rarely needs to be more than 100 to 150 KB. If your LCP image is a 900 KB PNG, converting it is the fastest win on this list. For quick checks, run a few images through Squoosh. For a whole site, use your image CDN or build pipeline.

5. Serve images from your own origin, or preconnect. An image on a third-party CDN needs a new DNS lookup, TCP and TLS connection, which can be 200 to 500 ms on mobile. Either serve it through your main domain or add <link rel="preconnect" href="https://images.example-cdn.com"> early in the head.

6. Replace auto-playing hero carousels. The first slide is usually lazy, JavaScript-dependent or swapped out before it paints, so the browser keeps updating the LCP candidate. One static hero image converts better anyway.

Verify: in the DevTools Network panel, the LCP image should start downloading within a few hundred milliseconds of the HTML response, with priority "High". In RUM, p75 loadDelay for the template should fall to a small fraction of the total.

Step 6: Remove what blocks the render

If element render delay dominates, the image or headline has arrived but something prevents it from painting. The usual suspects:

Render-blocking CSS and JavaScript in the head. Every stylesheet in the head blocks rendering until it's downloaded and parsed, and so does every script without defer or async. Inline the small amount of CSS the first screen needs, and load the rest normally. Add defer to every script that doesn't have to run before first paint, which is nearly all of them:

<script src="/js/app.js" defer></script>

A/B testing and personalization "anti-flicker" snippets. These hide the whole page (often with opacity: 0 on the body) until the testing script has loaded, with timeouts of up to several seconds. That timeout becomes your render delay. Remove the snippet, run tests server-side or at the edge, or at minimum cut the timeout and limit hiding to the element under test.

Client-side rendering of the first screen. If the hero headline comes from a React component that only renders after the JavaScript bundle loads and fetches data, the render delay is your bundle plus your API call. Server-render the first screen. In Next.js App Router, that means keeping the hero in a Server Component and not putting "use client" at the top of the page.

Web fonts on a text LCP. If the LCP element is a headline in a web font that's still loading, the browser may wait to show it. Use font-display: swap (or optional for the strictest LCP), self-host the font, and preload only the one or two files the first screen uses. In Next.js, next/font self-hosts and configures this for you:

import { Inter } from "next/font/google";
const inter = Inter({ subsets: ["latin"], display: "swap" });

The cookie banner becomes the LCP element. On a mobile screen, a large consent banner's text block can be the largest element. If the consent platform loads late, LCP waits for it. Load the consent script early, keep the banner compact, and check in DevTools which element is actually reported as LCP.

Verify: record a throttled reload in DevTools. The gap between the LCP resource finishing and the LCP marker should be under about 100 ms. In RUM, p75 renderDelay should be a small fraction of LCP.

Bonus, for repeat navigations: Chromium browsers support speculation rules, which prerender a likely next page while the user is still on this one, so the next navigation's LCP is near zero:

<script type="speculationrules">
{
  "prerender": [{
    "where": { "and": [{ "href_matches": "/*" }, { "not": { "href_matches": "/cart*" } }] },
    "eagerness": "moderate"
  }]
}
</script>

moderate starts prerendering when a user hovers or presses on a link for a moment. Exclude anything with side effects, like cart, logout or anything that changes state on GET, and make sure your analytics only counts prerendered pages once they're actually shown.

Step 7: Fix INP by finding the slow interaction

INP is the metric most sites fail in 2026, and the one checklists handle worst. That's because it only happens when a real person interacts. Lighthouse loads a page without clicking anything, so it can't measure INP at all. Its "Total Blocking Time" metric is only a rough proxy.

Every interaction has three parts, and the attribution build reports each one:

  • Input delay: the browser is busy with something else (a long task, often third-party JavaScript running during page load) and can't even start your event handler.
  • Processing duration: your event handlers themselves take too long.
  • Presentation delay: after the handlers finish, the browser needs a long time for style, layout and paint, usually because the change touches a huge DOM.

Find the culprit in your RUM data. Filter INP rows rated "poor" and group by inpTarget and longestScript. You'll typically find one of three patterns:

  1. A specific control, like the "Add to cart" button, a filter checkbox or the mobile menu toggle, with high processing time. That means your own code.
  2. Many different targets with high input delay and loadState of "loading" or "dom-interactive". People tap while the page is still running startup JavaScript. That usually means third-party tags or a heavy hydration step.
  3. High presentation delay on pages with very large DOMs, like long category grids, mega-menus, or comments.

Reproduce it. In DevTools → Performance, set CPU throttling to 4× or 6× (a mid-range phone is several times slower than your laptop), start recording, perform the interaction, stop. Look for the interaction in the Interactions track and the long yellow scripting blocks under it. The Bottom-up tab tells you which functions took the time.

Fix 1: show feedback first, do the work after. The next paint only has to show that something happened. Update the button state, then yield to the main thread so the browser can paint, then do the expensive work. This helper uses scheduler.yield() where it exists (Chrome since version 129, Firefox since 142) and falls back to setTimeout (Safari):

export function yieldToMain() {
  if (globalThis.scheduler?.yield) return scheduler.yield();
  return new Promise((resolve) => setTimeout(resolve, 0));
}

addToCartButton.addEventListener("click", async () => {
  addToCartButton.disabled = true;
  addToCartButton.textContent = "Adding…";   // visible feedback in the next frame
  await yieldToMain();                         // let the browser paint it

  await addItemToCart(productId);              // network + state update
  await yieldToMain();
  updateMiniCart();                            // heavy DOM work, now off the critical path
  sendAnalyticsEvent("add_to_cart", productId);
});

Fix 2: break up long loops. Any loop that processes hundreds of items, like filtering a product list or rendering search results, should yield every 50 ms or so:

async function processInChunks(items, handle) {
  let deadline = performance.now() + 50;
  for (const item of items) {
    handle(item);
    if (performance.now() > deadline) {
      await yieldToMain();
      deadline = performance.now() + 50;
    }
  }
}

Fix 3: in React, mark non-urgent updates as transitions. Typing in a search box should update the input immediately. The filtered result list can lag a frame:

import { useState, useTransition } from "react";

function ProductFilter({ products }) {
  const [query, setQuery] = useState("");
  const [visible, setVisible] = useState(products);
  const [isPending, startTransition] = useTransition();

  return (
    <>
      <input
        value={query}
        onChange={(e) => {
          setQuery(e.target.value);                        // urgent: the keystroke
          startTransition(() => {
            setVisible(products.filter((p) => p.name.toLowerCase().includes(e.target.value.toLowerCase())));
          });                                              // interruptible: the list
        }}
      />
      <ProductGrid products={visible} dimmed={isPending} />
    </>
  );
}

Fix 4: tame third-party scripts. Tag managers routinely carry a dozen tags nobody remembers adding. Audit the container: remove dead tags, fire non-essential ones on window load or later instead of "Page View", and load chat widgets only after an interaction or after a delay. Each tag you remove cuts input delay for every visitor during page load.

Fix 5: shrink the work the browser has to redo. For presentation delay, cut DOM size (paginate or virtualize long lists, don't render hidden mega-menu content until it opens), and add content-visibility: auto with a contain-intrinsic-size to long below-the-fold sections, so the browser skips laying them out until they're near the viewport:

.product-grid-section,
.reviews-section {
  content-visibility: auto;
  contain-intrinsic-size: auto 1200px;
}

Avoid reading layout (offsetHeight, getBoundingClientRect) right after writing styles in a loop. That forces the browser to recalculate layout on every iteration.

Verify: repeat the throttled DevTools recording. The interaction should show a short first task followed by separate tasks, with the next frame painted inside 200 ms. In RUM, the poor INP rows for that target should disappear within a few days of the deploy. Re-check the top three targets each week until p75 is under 200 ms.

Step 8: Stop layout shifts at the source

CLS problems are almost always one of five causes, and each has a precise fix. Your RUM data's clsTarget shows the element that moved most. In Chrome DevTools, the Performance panel's Layout shifts track shows the shift clusters, and the Rendering drawer's "Layout Shift Regions" option flashes shifted areas live while you browse.

1. Images, videos and iframes without dimensions. Always set width and height attributes (the browser uses their ratio to reserve space even when CSS makes the image responsive), or use CSS aspect-ratio:

img, video { max-width: 100%; height: auto; }
.video-embed { aspect-ratio: 16 / 9; width: 100%; }

next/image sets dimensions automatically for static imports. For remote images, pass width and height, or use fill inside a sized container.

2. Content injected above existing content. Promo bars, cookie banners, "app download" banners and late-loading ads that push the page down. The fix is to reserve the space up front with a fixed-height slot, or to render the element as an overlay (position: fixed) that doesn't move anything:

.ad-slot-top { min-height: 250px; }          /* the most common size for this slot */
.cookie-banner { position: fixed; inset: auto 0 0 0; }

3. Web fonts swapping in with different metrics. When the fallback font and the web font have different widths, text reflows on swap and shifts everything below. Adjust the fallback to match. next/font does this automatically. In plain CSS:

@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}
body { font-family: "Inter", "Inter Fallback", sans-serif; }

The exact percentages depend on your font. Tools such as Fontaine or Capsize calculate them for you.

4. Animations that move layout. Animating top, left, height or margin shifts content. Animate transform and opacity instead. They don't trigger layout and don't count as layout shifts.

5. Pages that can't use the back/forward cache. Returning to a page from the bfcache is instant and shift-free. A page that can't use it reloads, and may shift again. The common blockers are unload event listeners (often from old analytics or chat scripts) and open connections. Check in DevTools → Application → Back/forward cache → "Test back/forward cache". It lists the exact reasons a page isn't eligible.

Shifts that happen within 500 ms of a user's tap or click don't count, so an accordion that opens on tap is fine. A product grid that reflows when "Load more" results arrive two seconds later is not. Insert them below the viewport position or reserve their space.

Verify: browse the template on a throttled phone profile with Layout Shift Regions on. Nothing should flash during load except deliberate, tapped changes. In RUM, p75 CLS for the template should drop under 0.1, which is under 100 in the stored integer value.

Step 9: Lock the gains in with Lighthouse CI

Every site that fixes its Core Web Vitals and does nothing else regresses within two or three releases. Someone adds a tag, a new hero component ships with lazy loading, a font is swapped. The defense is an automated check on every pull request.

Add a lighthouserc.json at the repository root:

{
  "ci": {
    "collect": {
      "startServerCommand": "npm run start",
      "startServerReadyPattern": "Ready",
      "url": [
        "http://localhost:3000/",
        "http://localhost:3000/products/blue-sofa",
        "http://localhost:3000/category/sofas"
      ],
      "numberOfRuns": 3
    },
    "assert": {
      "assertions": {
        "largest-contentful-paint": ["error", { "maxNumericValue": 3000, "aggregationMethod": "median-run" }],
        "cumulative-layout-shift": ["error", { "maxNumericValue": 0.1, "aggregationMethod": "median-run" }],
        "total-blocking-time": ["warn", { "maxNumericValue": 300, "aggregationMethod": "median-run" }],
        "resource-summary:script:size": ["warn", { "maxNumericValue": 350000 }]
      }
    },
    "upload": { "target": "temporary-public-storage" }
  }
}

The lab LCP budget (3,000 ms) is deliberately a little looser than the field target. Lighthouse's default mobile emulation is harsher than most real visitors, and a budget that fails on noise gets disabled within a week. Total Blocking Time is the lab stand-in for INP. Use one URL per template, not your whole sitemap.

Then add a GitHub Actions workflow:

# .github/workflows/lighthouse.yml
name: Lighthouse CI
on: [pull_request]

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run build
      - run: npx @lhci/cli@0.16.1 autorun

temporary-public-storage uploads each report to a public URL for a few days, which is convenient for small teams. If your pages shouldn't be public, run your own LHCI server or use "target": "filesystem" and keep the reports as build artifacts.

Verify: open a test pull request that adds loading="lazy" to your hero image. The Lighthouse job should fail on largest-contentful-paint. Revert it, and it should pass.

Two more guardrails worth adding: a weekly CrUX check (the curl from Step 1 in a scheduled job, alerting when any template's p75 crosses "needs improvement"), and a simple rule for third-party tags: every new tag needs an owner, a reason and a load trigger later than page view, agreed before it goes into the tag manager.

Step 10: Validate in Search Console and watch the 28 days

Once the fixes are live and your RUM data shows the template passing at p75, go back to Experience → Core Web Vitals in Search Console, open the issue, and click Validate fix. Google then monitors the affected URLs for 28 days. The issue moves to "Passed" when the field data confirms it, or to "Failed" if it doesn't. Don't start a second validation mid-way. It resets the clock.

While you wait, track progress yourself with the CrUX history endpoint:

curl -s "https://chromeuxreport.googleapis.com/v1/records:queryHistoryRecord?key=$CRUX_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origin": "https://www.example.com", "formFactor": "PHONE", "metrics": ["largest_contentful_paint"]}' \
  | jq '.record.metrics.largest_contentful_paint.percentilesTimeseries.p75s'

Each value is a 28-day window ending one week later than the previous one, so after a good deploy you'll see the p75 step down over four consecutive weeks rather than all at once.

Platform notes: WordPress, Shopify and Next.js

WordPress. Most problems come from the theme and plugins, not WordPress itself. Run a full-page cache (at the host or with a caching plugin) so HTML is served from cache. Check that your theme doesn't lazy-load the first content image (WordPress core skips lazy-loading for the first image and adds fetchpriority="high" to it, but page builders and optimization plugins often override that). Audit plugins that add front-end JavaScript to every page: sliders, popups, social feeds, page builders. Be careful with "delay all JavaScript" settings in optimization plugins. They improve lab scores by deferring scripts until the first interaction, which can make that first tap slower and hurt INP.

Shopify. You can't change the server, so TTFB is mostly fixed. The work is in the theme and the apps. Each installed app can inject scripts into every page, even after you uninstall it if leftover snippets stay in the theme. Remove dead app code, use the theme's image_url and image_tag filters with explicit widths and fetchpriority: 'high' on the hero, and replace JavaScript-heavy sections with native theme features where possible. This is the kind of work we do as Shopify improvements.

Next.js. Keep the first screen in Server Components. Watch your client bundle (@next/bundle-analyzer shows what each route ships). Use next/image and next/font as shown above. Load third-party scripts through next/script with strategy="lazyOnload" for anything non-essential. And statically render with revalidation wherever the content allows it.

Common pitfalls and how to debug them

  • "Lighthouse says 98, Search Console says Poor." Lighthouse is one simulated load on a fast machine with no cookies, no consent banner, no logged-in state and no interactions. Trust the field data, find the gap with RUM attribution, and check what real users have that the lab doesn't: campaign redirects, consent platforms, personalization, older phones.
  • "We fixed it two weeks ago and nothing changed." The CrUX window is 28 days. Check your own RUM data. If p75 dropped there, Google's numbers will follow.
  • "LCP got worse after we optimized images." Usually a lazy-loading plugin now applies to the hero, or the new responsive images are missing sizes and phones download the largest file. Check the LCP image's priority and transferred size in the Network panel.
  • "INP is bad but we can't reproduce it." You're testing on a fast laptop. Throttle the CPU 4× to 6×, test on a real mid-range Android phone, and interact while the page is still loading. That's when input delay peaks.
  • "CLS is fine in the lab and bad in the field." Lab tests stop measuring after load. Real users scroll, and shifts below the fold (lazy images without dimensions, ads, infinite lists) count too. Scroll through the page with Layout Shift Regions enabled.
  • "Only the origin is failing, no individual URL." Low-traffic URLs inherit the origin's data. Fix your highest-traffic templates and the origin follows.
  • "A/B tests make our numbers swing." Each variant can have different performance. Tag RUM rows with the variant and compare p75s before you pick a winner.

What this costs, in time and money

The tools are free: Search Console, PageSpeed Insights, the CrUX API, Chrome DevTools, web-vitals and Lighthouse CI. Paid real-user monitoring services save you building the storage and dashboards, and typically start in the tens of euros per month. They're worth it once you have more than a handful of templates or several teams shipping.

The real cost is developer time. Measurement and triage take half a day. Monitoring and root-cause analysis take one to two days. The fixes typically take 3 to 10 days for a business site or a mid-sized shop. Simple sites with one bad hero image can be done in an afternoon. Sites carrying years of tags, apps and plugins take longer, and that's also where the biggest wins are. Add the 28-day field window, and plan on four to six weeks from first measurement to a validated "Passed" in Search Console.

FAQ

What are good Core Web Vitals scores? A page passes when, at the 75th percentile of real visits, Largest Contentful Paint is 2.5 seconds or less, Interaction to Next Paint is 200 milliseconds or less, and Cumulative Layout Shift is 0.1 or less. Google measures mobile and desktop separately using Chrome UX Report data over a rolling 28-day window.

How long does it take for Core Web Vitals improvements to show in Google Search Console? About 28 days. Search Console uses a rolling 28-day window of real-user Chrome data, so a fix shipped today shows up in part after the first week and in full after four weeks. Use your own real-user monitoring to confirm the improvement immediately, then click Validate fix in Search Console.

Why is my Lighthouse score good but my Core Web Vitals fail? Lighthouse runs one simulated page load in a lab and can't measure INP at all, because it never clicks anything. Google ranks on field data from real Chrome users, who have slower phones, worse networks, consent banners, campaign redirects and third-party scripts that the lab doesn't reproduce. Always fix based on field data and real-user attribution.

What is the most common cause of a slow LCP? In our experience it's late discovery of the LCP image rather than its file size: a hero image that's lazy-loaded, set as a CSS background, or injected by JavaScript. Break LCP into its four subparts (time to first byte, resource load delay, resource load duration, element render delay) and fix whichever is largest.

How do I fix a poor INP score? Find the slow interaction with the web-vitals attribution build, which reports the element, the input delay, processing duration, presentation delay and the longest script. Then give visual feedback first and yield to the main thread before doing heavy work, break up long tasks, delay non-essential third-party scripts, and reduce DOM size.

Do Core Web Vitals affect Google rankings? Yes, as part of the page experience signals, but as a tie-breaker between pages of similar relevance rather than a way to outrank better content. The larger effect is on conversion and bounce rate, because slow, janky pages lose visitors whether or not ranking changes.

Can I improve Core Web Vitals on Shopify or WordPress? Yes. On Shopify, the work is in the theme and installed apps: remove unused app scripts, prioritize the hero image and limit JavaScript-heavy sections. On WordPress, use full-page caching, check that the first image isn't lazy-loaded, and remove plugins that load scripts on every page.

Do it yourself, or have it done right the first time

Everything in this guide can be done by a capable developer with access to your code and your Search Console. The method stays the same at any scale: field data first, attribution on real users, the biggest subpart first, and a CI budget so the gains stick. It's also where teams lose the most time, by optimizing what Lighthouse flags instead of what real users hit, or by shipping a fix that the next tag or theme update quietly undoes.

Copy & paste

Do it: the full prompt

Copy this prompt into any LLM or coding agent (Claude, ChatGPT, Cursor …) to apply this guide to your own project.

Guide: https://blackcard.dev/guides/how-to-improve-your-core-web-vitals
Markdown version (fetch this for the full method): https://blackcard.dev/guides/how-to-improve-your-core-web-vitals.md

Act as my web performance engineer and improve my site's Core Web Vitals using the method from the guide "How to Improve Your Core Web Vitals" (blackcard.dev).

My situation:
- Site URL: [https://www.example.com]
- Stack and hosting: [e.g. Next.js 15 on Netlify / WordPress with theme X / Shopify with theme Y]
- Search Console Core Web Vitals report (mobile): [e.g. LCP issue on 340 product URLs, p75 3.9s; INP issue on 120 URLs, p75 310ms]
- Most important templates: [product, category, home, landing pages]
- Third-party scripts on every page: [GTM with N tags, GA4, chat widget, consent platform, A/B testing]

Steps:
1. Give me the exact CrUX API calls to get p75 LCP, INP and CLS for my origin and one URL per template, on PHONE.
2. Write the real-user monitoring code for my stack using web-vitals 6 (attribution build): LCP subparts, INP target, input delay, processing duration, presentation delay and longest script, CLS largest shift target, tagged by page template, sent with sendBeacon on visibilitychange, plus the endpoint and the p75-per-template query.
3. For each failing template, tell me how to reproduce the problem in Chrome DevTools with CPU and network throttling, and which subpart to fix first.
4. Give me concrete code changes for my stack: caching headers or static rendering for TTFB, LCP image markup with fetchpriority and responsive sizes, removal of render-blocking resources, a yieldToMain helper for slow interactions, and reserved space or font metric overrides for layout shifts.
5. Write a lighthouserc.json with one URL per template and a GitHub Actions workflow running @lhci/cli autorun on pull requests.
6. Tell me when to click Validate fix in Search Console and how to track the 28-day progress with the CrUX history endpoint.
Ask me for anything you need from my code or my reports before writing changes, and keep every change small enough to review.

If you'd rather have it done properly in one pass (field data analyzed, monitoring installed, root causes fixed in your actual theme or codebase, CI budgets in place, and a validated "Passed" in Search Console), that's work we do every week. We build and speed up shops, portals and business sites as part of our business software work, fix the interaction design behind slow or jumpy pages in UI/UX, and help you decide which performance work is worth paying for through consulting. Planning a redesign at the same time? Our relaunch playbook shows how to protect both your rankings and your speed.

Book a free call and bring your Search Console Core Web Vitals report. We'll tell you which templates fail, why, and what it takes to fix them.