Interpret browser responsiveness and web vitals
Understand the three Core Web Vitals
Largest Contentful Paint (LCP) tracks when a large eligible content element is painted during loading. Interaction to Next Paint (INP) characterizes responsiveness across qualifying interactions over a page visit, including input delay, processing and presentation delay. Cumulative Layout Shift (CLS) captures unexpected visual movement using the largest qualifying session window. LCP and INP are durations, commonly reported in milliseconds; CLS is unitless. Good thresholds are LCP at most 2500 ms, INP at most 200 ms, CLS at most 0.1. Poor thresholds are above 4000 ms, 500 ms and 0.25 respectively. Evaluate the 75th percentile of field page visits for each metric, separating mobile and desktop. A lab trace is useful for diagnosis but cannot establish a field percentile. Do not average percentiles across cohorts; aggregate observations or suitable distributions instead.
const limits={LCP:[2500,4000],INP:[200,500],CLS:[0.1,0.25]};export function classify(name,value){ if(!Object.hasOwn(limits,name)||!Number.isFinite(value)||value<0) throw new RangeError('Invalid metric'); const [good,poor]=limits[name]; return value<=good?'good':value<=poor?'needs improvement':'poor';}For example, classify("INP", 200) is good; 201 needs improvement; 501 is poor. These values are hypothetical inputs. A missing measurement (for example a visit with no qualifying interaction) is not a zero. This function classifies one supplied value, not a population, and does not compute the metric itself.
Collect browser observations without sending data
import {onCLS,onINP,onLCP} from 'web-vitals';const report=({name,value})=>console.info({name,value});onCLS(report);onINP(report);onLCP(report);Run this module once in the browser entry of an approved build with a compatible web-vitals package. Callback timing depends on the metric and page lifecycle; an interaction or leaving the page may be necessary. The library handles metric calculation details. Do not interpret absence of a log as zero, do not register observers on every render, and do not treat local samples as field data. For real telemetry, minimize data and establish privacy, retention and sampling policies before collecting anything. The example sends nothing to a server.
export function measureWork(work){ const start=performance.now(); const result=work(); return {result,elapsedMs:performance.now()-start};}This helper uses a monotonic timer around synchronous JavaScript only. It is not an INP measurement, does not await asynchronous operations, and does not include subsequent rendering or painting. A useful browser experiment is to record a click in the Performance panel, inspect input delay, JavaScript and presentation, and compare with this narrower measurement. To improve LCP, inspect the critical resource and avoid lazy-loading the main hero image; to improve CLS reserve image or embed dimensions and avoid shifting existing content; to improve INP investigate long tasks and expensive event handling. Test each change separately. Network caching, font loading and image compression may matter more than React memoization.