Web Performance: Core Web Vitals
Overview
Core Web Vitals are the subset of Web Vitals that Google considers essential signals of real-user experience: loading (LCP), interactivity (INP), and visual stability (CLS). Read this when you need to measure page performance against objective field thresholds and prioritize fixes that affect actual users rather than synthetic lab scores alone.
Official sources
Install / setup
npm install web-vitals
Core concepts
- The three Core Web Vitals. LCP (Largest Contentful Paint) measures loading, INP (Interaction to Next Paint) measures interactivity, and CLS (Cumulative Layout Shift) measures visual stability.
- "Good" thresholds at the 75th percentile. Per web.dev: LCP within 2.5 s, INP of 200 ms or less, CLS of 0.1 or less — assessed at the 75th percentile of page loads, split across mobile and desktop.
- Field (RUM) vs lab data. Core Web Vitals are defined against real-user (field) data such as the Chrome User Experience Report; lab tools like Lighthouse approximate but cannot replace field measurement.
- LCP load breakdown. web.dev decomposes LCP into time to first byte, resource load delay, resource load duration, and element render delay — optimizing LCP is largely about loading the LCP resource sooner and faster.
- Layout shift scoring. CLS sums layout shift scores (impact fraction x distance fraction) from unexpected shifts; shifts within 500 ms of user input are excluded.
- Performance APIs. Browsers expose timing via the Navigation Timing, Resource Timing, and Long Animation Frame APIs (see MDN), which the web-vitals library reads through
PerformanceObserver.
Best practices
- Measure with the official library on real users. Use
web-vitals (onLCP, onINP, onCLS) with its buffered PerformanceObserver flag so metrics match Chrome's own reporting; send results to your analytics endpoint.
- Make the LCP resource discoverable early. Per the optimize-LCP guide, include it in the initial HTML, set appropriate
fetchpriority, and avoid loading it via JavaScript that delays discovery.
- Reserve space to prevent CLS. Set explicit
width/height (or aspect-ratio) on images and media, and avoid inserting content above existing content after load.
- Reduce main-thread work for INP. Break up long tasks and minimize JavaScript executed during interactions so the next paint after an input happens within 200 ms.
- Cut TTFB. Minimize redirects and serve cacheable HTML from CDN edge servers, since TTFB is the floor for LCP.
Common pitfalls
- Optimizing only lab scores → Lighthouse is a lab approximation; ship against field/CrUX data because that is what Core Web Vitals are measured on.
- Treating averages as the target → thresholds are evaluated at the 75th percentile across devices; a good average can still fail at p75 on slow mobile.
- Lazy-loading the LCP image → deferring the largest above-the-fold element delays its load and inflates LCP; eager-load it instead.
- Ignoring INP because FID looked fine → INP replaced FID as a Core Web Vital and considers all interactions across the page lifecycle, not just the first input.
Examples
import { onLCP, onINP, onCLS } from 'web-vitals';
function send(metric) {
// metric: { name, value, rating, delta, id }
navigator.sendBeacon('/analytics', JSON.stringify(metric));
}
onLCP(send);
onINP(send);
onCLS(send);
Further reading
Related skills
- ../profiling-and-benchmarking — measuring before optimizing, browser profilers
- ../backend-performance — server-side TTFB and load handling that feeds LCP
1---2name: web-performance-core-vitals3description: Measure and optimize Core Web Vitals (LCP, INP, CLS) for real-user front-end performance; consult when tuning page load and interactivity.4domain: engineering5category: performance6tags: [web-vitals, lcp, inp, cls, frontend, rum, performance]7official_sources:8 - https://web.dev/articles/vitals9 - https://github.com/GoogleChrome/web-vitals10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/web-performance-core-vitals13---1415# Web Performance: Core Web Vitals1617## Overview18Core Web Vitals are the subset of Web Vitals that Google considers essential signals of real-user experience: loading (LCP), interactivity (INP), and visual stability (CLS). Read this when you need to measure page performance against objective field thresholds and prioritize fixes that affect actual users rather than synthetic lab scores alone.1920## Official sources21- Docs: https://web.dev/articles/vitals22- Optimize LCP guide: https://web.dev/articles/optimize-lcp23- MDN performance hub: https://developer.mozilla.org/en-US/docs/Web/Performance24- Repo (measurement library): https://github.com/GoogleChrome/web-vitals25- Install / download: https://www.npmjs.com/package/web-vitals2627## Install / setup28```bash29npm install web-vitals30```3132## Core concepts33- **The three Core Web Vitals.** LCP (Largest Contentful Paint) measures loading, INP (Interaction to Next Paint) measures interactivity, and CLS (Cumulative Layout Shift) measures visual stability.34- **"Good" thresholds at the 75th percentile.** Per web.dev: LCP within 2.5 s, INP of 200 ms or less, CLS of 0.1 or less — assessed at the 75th percentile of page loads, split across mobile and desktop.35- **Field (RUM) vs lab data.** Core Web Vitals are defined against real-user (field) data such as the Chrome User Experience Report; lab tools like Lighthouse approximate but cannot replace field measurement.36- **LCP load breakdown.** web.dev decomposes LCP into time to first byte, resource load delay, resource load duration, and element render delay — optimizing LCP is largely about loading the LCP resource sooner and faster.37- **Layout shift scoring.** CLS sums layout shift scores (impact fraction x distance fraction) from unexpected shifts; shifts within 500 ms of user input are excluded.38- **Performance APIs.** Browsers expose timing via the Navigation Timing, Resource Timing, and Long Animation Frame APIs (see MDN), which the web-vitals library reads through `PerformanceObserver`.3940## Best practices41- **Measure with the official library on real users.** Use `web-vitals` (`onLCP`, `onINP`, `onCLS`) with its `buffered` PerformanceObserver flag so metrics match Chrome's own reporting; send results to your analytics endpoint.42- **Make the LCP resource discoverable early.** Per the optimize-LCP guide, include it in the initial HTML, set appropriate `fetchpriority`, and avoid loading it via JavaScript that delays discovery.43- **Reserve space to prevent CLS.** Set explicit `width`/`height` (or `aspect-ratio`) on images and media, and avoid inserting content above existing content after load.44- **Reduce main-thread work for INP.** Break up long tasks and minimize JavaScript executed during interactions so the next paint after an input happens within 200 ms.45- **Cut TTFB.** Minimize redirects and serve cacheable HTML from CDN edge servers, since TTFB is the floor for LCP.4647## Common pitfalls48- **Optimizing only lab scores** → Lighthouse is a lab approximation; ship against field/CrUX data because that is what Core Web Vitals are measured on.49- **Treating averages as the target** → thresholds are evaluated at the 75th percentile across devices; a good average can still fail at p75 on slow mobile.50- **Lazy-loading the LCP image** → deferring the largest above-the-fold element delays its load and inflates LCP; eager-load it instead.51- **Ignoring INP because FID looked fine** → INP replaced FID as a Core Web Vital and considers all interactions across the page lifecycle, not just the first input.5253## Examples54```js55import { onLCP, onINP, onCLS } from 'web-vitals';5657function send(metric) {58 // metric: { name, value, rating, delta, id }59 navigator.sendBeacon('/analytics', JSON.stringify(metric));60}6162onLCP(send);63onINP(send);64onCLS(send);65```6667## Further reading68- https://web.dev/articles/optimize-lcp — optimizing LCP step by step69- https://web.dev/articles/cls — understanding and reducing layout shift70- https://developer.mozilla.org/en-US/docs/Web/Performance — MDN performance guides and APIs7172## Related skills73- ../profiling-and-benchmarking — measuring before optimizing, browser profilers74- ../backend-performance — server-side TTFB and load handling that feeds LCP