Answer
Core Web Vitals (field metrics):
- LCP (Largest Contentful Paint) — loading, target < 2.5s.
- CLS (Cumulative Layout Shift) — visual stability, target < 0.1.
- INP (Interaction to Next Paint) — responsiveness, target < 200ms (replaced FID).
Tools:
- Lighthouse / PageSpeed Insights — lab audits + suggestions.
- Chrome DevTools Performance & Network panels — flame charts, waterfalls.
PerformanceObserver/ Navigation & Resource Timing APIs — real user monitoring (RUM).web-vitalslibrary to report metrics to analytics.
// Measure a code block
performance.mark("start");
doWork();
performance.mark("end");
performance.measure("work", "start", "end");
console.log(performance.getEntriesByName("work")[0].duration);
// Observe LCP
new PerformanceObserver((list) => {
for (const entry of list.getEntries()) console.log("LCP", entry.startTime);
}).observe({ type: "largest-contentful-paint", buffered: true });