DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
  1. Home
  2. Articles
  3. Frontend Engineering
  4. Web Performance: Core Web Vitals Optimization Guide
XLinkedInReddit
MediumFrontend Engineering

Web Performance: Core Web Vitals Optimization Guide

D
DevPrep Team
February 10, 2026·1 min read·0
Table of Contents
  • The Three Vitals
  • LCP (Largest Contentful Paint) — Target: < 2.5s
  • INP (Interaction to Next Paint) — Target: < 200ms
  • CLS (Cumulative Layout Shift) — Target: < 0.1
  • LCP Optimization
  • INP Optimization
  • CLS Optimization
  • Measurement

Core Web Vitals directly impact search rankings and user experience. At Google, we obsess over these metrics.

The Three Vitals

LCP (Largest Contentful Paint) — Target: < 2.5s

Measures when the largest visible element finishes rendering. Usually a hero image, heading, or video poster.

INP (Interaction to Next Paint) — Target: < 200ms

Measures responsiveness. The time from user interaction to the next visual update. Replaced FID in 2024.

CLS (Cumulative Layout Shift) — Target: < 0.1

Measures visual stability. How much visible content shifts unexpectedly during page load.

LCP Optimization

<!-- Preload critical resources -->
<link rel="preload" href="/hero.webp" as="image" fetchpriority="high">

<!-- Use fetchpriority for LCP images -->
<img src="/hero.webp" fetchpriority="high" width="1200" height="600" alt="Hero">

<!-- Inline critical CSS -->
<style>/* Critical above-the-fold styles */</style>
<link rel="stylesheet" href="/full.css" media="print" onload="this.media='all'">

INP Optimization

  • Break long tasks with scheduler.yield() or setTimeout(0)
  • Use requestIdleCallback for non-critical work
  • Virtualize long lists (react-window, tanstack-virtual)
  • Debounce input handlers, not the visual feedback

CLS Optimization

  • Always set width and height on images and videos
  • Use aspect-ratio CSS for responsive containers
  • Reserve space for dynamic content (ads, embeds)
  • Avoid inserting content above the fold after initial render
  • Use font-display: optional for web fonts to prevent FOIT

Measurement

import { onLCP, onINP, onCLS } from "web-vitals";
onLCP(console.log);
onINP(console.log);
onCLS(console.log);

Related Articles

MediumFrontend Engineering

System Design #12: Design a Multi-Step Form Wizard

7 min read
MediumFrontend Engineering

Mastering Senior-Level JavaScript Interview Concepts

2 min read
MediumFrontend Engineering

System Design #9: Design a Collaborative Text Editor

9 min read

Comments (0)

Sign in to leave a comment.

No comments yet. Be the first to comment.

Table of Contents

  • The Three Vitals
  • LCP (Largest Contentful Paint) — Target: &lt; 2.5s
  • INP (Interaction to Next Paint) — Target: &lt; 200ms
  • CLS (Cumulative Layout Shift) — Target: &lt; 0.1
  • LCP Optimization
  • INP Optimization
  • CLS Optimization
  • Measurement

Series

View all Frontend Engineering articles →

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.