Skip to content

Web Performance and Core Web Vitals

Core Web Vitals 2026

Each Core Web Vital points at one bottleneck. LCP is the critical path: how fast the biggest thing on screen arrives and paints. INP is main-thread work: how long the page is too busy to answer a tap. CLS is layout stability: whether space was reserved before content arrived. Diagnose by metric first, then fix that bottleneck, because a fix for one rarely moves the others.

MetricGoodPoor
LCP — Largest Contentful Paint≤ 2.5 s> 4.0 s
INP — Interaction to Next Paint≤ 200 ms> 500 ms
CLS — Cumulative Layout Shift≤ 0.1> 0.25

Between the two columns is “needs improvement”. A page passes only when all three are good at the 75th percentile of real visits, measured separately for mobile and desktop. INP replaced First Input Delay as a Core Web Vital in 2024; web-vitals 5 removed onFID().

LCP load -> server, network, render path
INP respond -> JavaScript on the main thread
CLS stable -> missing sizes, late inserts
pass = all three "good" at p75, per device

Gotcha: The 75th percentile means a quarter of your users can have a bad experience while you still pass. Look at p75 on mobile first; it is usually the failing one.

SourceKindUse it to
CrUX, PageSpeed InsightsFieldSee what Google sees
web-vitals libraryField (RUM)Find which page and element
Lighthouse, DevToolsLabReproduce and debug
Total Blocking TimeLabProxy for INP

Field data is the truth and the ranking signal; lab data is a single synthetic load you can debug. Lab runs have no real interactions, so they cannot measure INP. The web-vitals attribution build tells you which element and which phase caused a bad value.

import {
onCLS, onINP, onLCP,
} from "web-vitals/attribution";
function send(m) {
const body = JSON.stringify({
name: m.name, value: m.value, id: m.id,
rating: m.rating, // "good" | ...
});
navigator.sendBeacon("/rum", body);
}
onCLS(send); onINP(send); onLCP(send);

Note: The LCP and Event Timing APIs (behind INP) reached Baseline in December 2025 with Safari 26.2, so RUM for those two now covers all engines. CLS still reports from Chromium only, and CrUX holds Chrome users only.

HintDoesBaseline
fetchpriority="high"Boosts one fetchNewly 2024
<link rel="preload">Fetch a late-found resource earlyWidely
<link rel="preconnect">Warm DNS, TCP, TLSWidely
<link rel="modulepreload">Fetch a module graph earlyWidely
<script defer>Run after parse, no blockWidely

LCP splits into four parts: time to first byte, resource load delay, resource load duration and element render delay. Most slow LCPs are load delay: the browser found the hero image late, because it sat in CSS, JavaScript or a lazy-loaded tag.

<link rel="preconnect"
href="https://img.example.com">
<link rel="stylesheet" href="/app.css">
<script src="/app.js" defer></script>
<img src="https://img.example.com/hero.avif"
width="1200" height="600"
fetchpriority="high" alt="Spring sale">

Gotcha: loading="lazy" on the LCP image delays it until layout proves it is in the viewport. Lazy-load only below-the-fold images.

TechniqueFixes
width + height on <img>CLS: space reserved
srcset + sizesLCP: right bytes per screen
AVIF or WebPLCP: fewer bytes
loading="lazy" below the foldBandwidth for the hero
font-display: swapText visible during font load
Preload one critical fontEarlier font, less swap shift

The browser derives an aspect ratio from width and height even when CSS makes the image fluid, so declare both on every image. Subset web fonts and ship WOFF2.

<link rel="preload" as="font" type="font/woff2"
href="/fonts/inter.woff2" crossorigin>
<style>
@font-face {
font-family: Inter;
src: url(/fonts/inter.woff2) format("woff2");
font-display: swap;
}
img { max-width: 100%; height: auto; }
</style>

Gotcha: Font preloads need crossorigin even on your own origin. Fonts are fetched in CORS mode, so without it the preload is not reused and the font downloads twice.

TechniqueEffect
import() on demandSplits a chunk off the entry
Route-level splittingEach page ships its own code
defer / type="module"Parse HTML without blocking
Drop or delay third partiesLess main-thread work
Bundle analyzer in CICatch size regressions

Every kilobyte of JavaScript costs download, parse, compile and execute time, and the last three land on the main thread. Load code when the user needs it, not when the page starts.

const btn = document.querySelector("#chart");
btn.addEventListener("click", async () => {
const { drawChart } = await import(
"./chart.js"
);
drawChart(document.querySelector("#out"));
});

Tip: Module scripts are deferred by default. async on a classic script runs it as soon as it arrives, which can block parsing at an unpredictable moment.

INP phaseCaused byFix
Input delayOther tasks runningBreak up long tasks
ProcessingYour handlersDo less, defer the rest
Presentation delayRendering, big DOMSmaller DOM, less layout

INP is the slowest interaction of the visit (ignoring one outlier per 50 interactions), from input to the next frame. A task over 50 ms is a long task. Paint the visible response first, then yield to the browser before the expensive work.

function yieldToMain() {
if (globalThis.scheduler?.yield) {
return scheduler.yield();
}
return new Promise((r) => setTimeout(r, 0));
}
async function onSave(btn, items) {
btn.textContent = "Saving…"; // visible first
await yieldToMain();
for (const item of items) {
process(item);
await yieldToMain();
}
}
function process(item) { /* heavy work */ }

Note: scheduler.yield() is not Baseline (no Safari), so keep the setTimeout fallback.

CauseFix
Image or video without sizewidth/height or aspect-ratio
Ad, embed, banner inserted lateReserve a min-height slot
Web font swapMatched fallback via size-adjust
Animating top/heightAnimate transform instead

A layout shift counts when a visible element moves without user input; shifts within 500 ms of a tap or keypress are excluded. CLS is the largest burst of shifts within a session window, not the page total.

.ad-slot { min-height: 250px; }
.embed { aspect-ratio: 16 / 9; width: 100%; }
@font-face {
font-family: "Inter Fallback";
src: local("Arial");
size-adjust: 107%;
}
body { font-family: Inter, "Inter Fallback"; }

Gotcha: Content inserted above the viewport after load, such as a cookie bar pushing the page down, is the classic CLS bug. Overlay it with position: fixed instead.

AssetCache-Control
Hashed JS, CSS, fontspublic, max-age=31536000, immutable
HTMLno-cache (revalidate every time)
API JSONprivate, max-age=0 or short s-maxage

Put a content hash in every static filename so it can be cached for a year and never revalidated; the HTML points to the new hash on deploy. Serve from a CDN close to users to cut TTFB, which is the first part of LCP. HTTP caching semantics are in the HTTP sheet.

Terminal window
curl -sI https://example.com/assets/app.3f9a.js \
| grep -i -E "cache-control|age|content-enc"

Gotcha: no-cache does not mean “do not store”. It means “revalidate before use”. no-store disables caching entirely.

Assertion keyTypical budget
largest-contentful-paintmaxNumericValue: 2500
cumulative-layout-shiftmaxNumericValue: 0.1
total-blocking-timemaxNumericValue: 200
categories:performanceminScore: 0.9

Lighthouse CI runs Lighthouse several times per URL and fails the build when an assertion breaks, so regressions surface in the pull request. Lab budgets catch regressions; only field data proves the fix.

{
"ci": {
"collect": { "numberOfRuns": 3 },
"assert": {
"assertions": {
"largest-contentful-paint":
["error", { "maxNumericValue": 2500 }],
"cumulative-layout-shift":
["error", { "maxNumericValue": 0.1 }],
"total-blocking-time":
["warn", { "maxNumericValue": 200 }]
}
}
}
}

Gotcha: Lighthouse 12 removed budget.json performance budgets, and Lighthouse 13 replaced many performance audits with insights. Assert on metric audit IDs, which survive those changes.