What are Core Web Vitals and how do you improve them?
MediumPerformanceCore Web Vitals
What are Core Web Vitals, and how do you improve each one?
TL;DR
Core Web Vitals are Google's three user-centric performance metrics, measured on real users at the 75th percentile:
- LCP (Largest Contentful Paint): loading, when the main content appears. Good: ≤ 2.5 s.
- INP (Interaction to Next Paint): responsiveness, the delay from a click or key press until the screen updates. Good: ≤ 200 ms. It replaced FID in 2024.
- CLS (Cumulative Layout Shift): visual stability, how much content jumps around. Good: ≤ 0.1.
They affect user experience and are a Google ranking signal.
Key points
LCP: find the LCP element (often the hero image), then:
- Don't lazy-load it; add
fetchpriority="high"or<link rel="preload">. - Serve modern formats (AVIF, WebP) at the right size, from a CDN.
- Reduce server response time (TTFB) and render-blocking CSS and JS.
INP: keep the main thread free:
- Break up long tasks (over 50 ms) and yield with
scheduler.yield()orsetTimeout. - Ship less JavaScript: code splitting, fewer third-party scripts.
- Give immediate visual feedback, and defer heavy work (
useTransitionin React).
CLS: reserve space:
- Set
width/heightoraspect-ratioon images, videos and ads. - Don't insert content above existing content; use
font-displayand matched fallback fonts.
Example
html
<img src="/hero.avif" width="1200" height="600" fetchpriority="high" alt="..." />
<img src="/below-fold.webp" width="400" height="300" loading="lazy" alt="..." />Common follow-ups
- Lab vs field data? Lighthouse is lab data (one simulated run). CrUX, PageSpeed Insights and the
web-vitalslibrary measure real users, and those numbers are what count. - What's TTFB? Time to first byte. It isn't a Core Web Vital, but a slow TTFB caps how good LCP can be.
What interviewers look for
Tip
Name all three with their thresholds, then give one concrete fix per metric.
- Red flag: still naming FID, or optimizing only for a Lighthouse score.