Performance

Mastering Core Web Vitals: A Frontend Engineer's Checklist

8 min read By Suraj Kumar Gorai

Core Web Vitals directly impact search rankings, user engagement, and conversion rates. After optimizing vitals across dozens of production sites, here's the checklist I follow to guarantee green scores across all three metrics.

LCP — Largest Contentful Paint (< 2.5s)

LCP measures how quickly the largest visible content element renders. For most pages, this is a hero image, heading, or video poster.

The LCP Checklist

  • Preload the LCP resource: Use <link rel="preload"> for the hero image or font used in the largest text block. Don't make the browser discover it through CSS or JS.
  • Optimize images: WebP/AVIF format, responsive srcset, proper width/height attributes. For above-the-fold images, use fetchpriority="high".
  • Eliminate render-blocking resources: Defer non-critical CSS. Inline critical CSS (above-the-fold styles) in a <style> tag. Use async/defer on scripts.
  • Server response time: Target TTFB under 600ms. Use CDN, enable compression (Brotli over Gzip), implement HTTP/2 or HTTP/3.
  • Font loading: Use font-display: swap. Preload the primary font. Subset fonts to include only characters you use.
  • Avoid lazy loading above-the-fold images: loading="lazy" on hero images delays LCP. Only lazy load below-the-fold content.

INP — Interaction to Next Paint (< 200ms)

INP replaced FID in March 2024 and measures the responsiveness of all user interactions, not just the first one. This is a much harder metric to ace.

The INP Checklist

  • Break up long tasks: Any JavaScript execution block exceeding 50ms is a "long task" that blocks the main thread. Use requestIdleCallback, setTimeout(fn, 0), or scheduler.yield() to break them into smaller chunks.
  • Minimize JavaScript: Every KB of JS is execution time on the main thread. Tree-shake aggressively. Remove unused polyfills. Audit your bundle with source-map-explorer.
  • Debounce expensive handlers: Search inputs, scroll handlers, resize listeners — debounce or throttle to prevent excessive DOM updates.
  • Avoid layout thrashing: Batch DOM reads and writes. Never read offsetHeight then immediately write to style.height in a loop.
  • Use CSS for animations: CSS transforms and opacity changes run on the compositor thread, bypassing the main thread entirely. Avoid animating width, height, top, left.
  • Web Workers for heavy computation: Data transformation, filtering large datasets, complex calculations — offload to a Web Worker to keep the main thread free for interactions.

CLS — Cumulative Layout Shift (< 0.1)

CLS measures visual stability. Every time a visible element shifts position unexpectedly, users lose trust and misclick.

The CLS Checklist

  • Explicit dimensions on media: Always set width and height on images and videos (or use aspect-ratio in CSS). This reserves space before the resource loads.
  • Reserve space for dynamic content: Ads, embeds, and lazy-loaded components should have min-height placeholders. Skeleton screens are both UX-friendly and CLS-friendly.
  • Avoid inserting content above existing content: Cookie banners, notification bars, and promo strips should push from the top with transform animations, not DOM insertion that shifts everything down.
  • Web fonts: Use font-display: optional for body text to prevent layout shift during font swap. Or use size-adjust on the fallback font to match metrics.
  • Contain layout changes: Use CSS contain: layout on components that might shift to prevent them from affecting siblings.

Measurement & Monitoring

  • Lab testing: Lighthouse CI in your deployment pipeline. Fail builds that regress vitals beyond thresholds.
  • Field data: Use the web-vitals library to capture real user metrics and send them to your analytics. Lab data alone is insufficient.
  • CrUX dashboard: Google's Chrome User Experience Report shows your real-world vital scores. Check monthly for trends.

Need help optimizing your site's Core Web Vitals? Get in touch — I've brought dozens of sites from red to green.