Skip to content

Core Web Vitals Explained — LCP, FID, CLS Optimization Guide

DodaTech Updated 2026-06-23 6 min read

In this tutorial, you will learn what Core Web Vitals are, how to measure LCP, FID, and CLS, and how to optimize each metric using practical techniques. Core Web Vitals are a set of real-world metrics that Google uses to evaluate page experience and influence search rankings. For example, Doda Browser uses Core Web Vitals to prioritize fast-loading pages in its search results, directly impacting user retention and engagement.

What You Will Learn

  • What Largest Contentful Paint (LCP) measures and how to keep it under 2.5 seconds
  • How First Input Delay (FID) affects interactivity and why it must stay below 100 milliseconds
  • What Cumulative Layout Shift (CLS) means and how to maintain a score under 0.1
  • How to use tools like Chrome DevTools and Lighthouse to debug vital issues

Why It Matters

Google officially made Core Web Vitals a ranking factor in 2021. Poor scores mean lower search visibility, higher bounce rates, and lost revenue. DodaTech products such as Doda Browser and the DodaZIP compression tool rely on fast rendering to deliver a seamless experience across devices.

Real-World Use Case

The DodaTech marketing team noticed a 22 percent bounce rate increase on pages where LCP exceeded 3 seconds. After optimizing hero images and removing render-blocking resources, LCP dropped to 1.8 seconds and organic traffic recovered within two weeks.

Prerequisites

Before starting this tutorial you should understand HTML document structure and how the CSS box model works. Familiarity with Chrome DevTools is helpful.

Step-by-Step Tutorial

Step 1: Understand Largest Contentful Paint (LCP)

LCP measures the time from when the page starts loading to when the largest content element becomes visible. This is typically a hero image, a video poster, or a large text block. Google recommends an LCP of 2.5 seconds or less.

To check your LCP, open Chrome DevTools, go to the Performance tab, and start a recording. Reload the page and look for the LCP marker in the timeline.

<!-- Example: A hero image that may be slow to load -->
<img src="hero-4k.jpg" alt="Hero banner" style="width:100%" />

Expected output in DevTools: LCP time displayed in milliseconds. If it exceeds 2500ms, the image needs optimization.

Step 2: Optimize LCP

The most effective LCP improvements include:

  1. Serve images in WebAssembly next-gen formats like WebP or AVIF
  2. Preload the LCP image using a <link rel="preload"> tag
  3. Minimize server response time (TTFB under 800ms)
  4. Eliminate render-blocking resources
<!-- Preload the LCP image -->
<link rel="preload" as="image" href="hero.webp" />

Step 3: Understand First Input Delay (FID)

FID measures the time from when a user first interacts with a page (clicking a button, tapping a link) to the time the browser can begin processing the event handler. Google recommends FID under 100 milliseconds.

FID is a field metric only — it cannot be measured in a lab. You need Real User Monitoring (RUM) data from tools like Google Analytics or the web-vitals library.

// Using the web-vitals library to measure FID
import {onFID} from 'web-vitals';

onFID(console.log);
// Output example: {name: 'FID', value: 45, ...}

A value of 45ms indicates good interactivity. Values above 100ms suggest JavaScript is blocking the main thread.

Step 4: Improve FID

To reduce FID:

  1. Break up long JavaScript tasks (longer than 50ms)
  2. Use Code Splitting and Lazy Loading for non-critical scripts
  3. Defer or async third-party scripts
  4. Use a web worker for heavy computations
// Using requestIdleCallback to defer non-critical work
requestIdleCallback(() => {
  // Load analytics or non-critical scripts here
  console.log('Deferred task ran during idle time');
});

Step 5: Understand Cumulative Layout Shift (CLS)

CLS measures visual stability by tracking unexpected layout shifts during the page lifecycle. Google recommends a CLS score below 0.1.

Layout shifts happen when elements change position after the user has already started viewing them. Common causes include images without dimensions, ads inserted dynamically, and web fonts causing FOIT/FOUT.

/* Prevent layout shift by setting explicit dimensions */
img, video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

Step 6: Reduce CLS

Key strategies to reduce CLS:

  1. Always set width and height attributes on images and videos
  2. Reserve space for ads and embeds
  3. Avoid inserting content above existing content
  4. Use font-display: optional for web fonts
  5. Use transform animations instead of layout-triggering properties
<!-- Set explicit dimensions to prevent shift -->
<img src="photo.webp" width="800" height="450" alt="Optimized photo" />

Learning Path

flowchart LR
  A[Core Web Vitals] --> B[Lighthouse Audits]
  A --> C[Caching Strategies]
  B --> D[Image Optimization]
  C --> D
  D --> E[Bundle Optimization]
  E --> F[Critical Rendering Path]
  
  style A fill:#4f46e5,color:#fff
  style B fill:#6366f1,color:#fff
  style C fill:#6366f1,color:#fff

Common Errors

  1. Measuring LCP with cached resources: Running Lighthouse with a warm cache gives unrealistically low LCP values. Always test with a cold cache and simulated throttling.

  2. Ignoring the LCP element: Some developers optimize every image except the LCP element itself. Use DevTools to identify which element is the LCP candidate.

  3. Setting height on responsive images without aspect-ratio: Without aspect-ratio CSS, a percentage-based height may still cause layout shifts.

  4. Deferring all JavaScript: Deferring all scripts can delay interactivity. Strategic inlining of critical scripts is better for FID.

  5. Relying solely on lab data: FID can only be measured with real users. Lab tools like Lighthouse show Total Blocking Time (TBT), which correlates with FID but is not identical.

  6. Using absolute positioning for layout: Absolute positioning removes elements from the document flow and can cause unexpected shifts on mobile.

Practice Questions

  1. What is the recommended LCP threshold according to Google?
  2. How does FID differ from Total Blocking Time?
  3. What causes a layout shift in CLS calculation?
  4. Why is aspect-ratio CSS property important for CLS?
  5. Name two tools that can measure Core Web Vitals in the field.

Answers: 1. 2.5 seconds. 2. FID is a field metric measuring real user interaction delay; TBT is a lab metric that sums all long task blocking periods. 3. Any visible element changing its start position between two frames. 4. It reserves the correct height before an image loads, preventing shifts. 5. Google Search Console and the web-vitals JavaScript library.

Challenge

Create a performance budget checker that monitors LCP, FID, and CLS using the PerformanceObserver API. Log a warning to the console whenever any metric exceeds the Google-recommended threshold. Deploy this as a snippet included in your site footer during development.

FAQ

What is the difference between LCP and FCP?

First Contentful Paint (FCP) marks the time when the first text or image is painted. LCP marks when the largest element is painted. LCP is more representative of perceived load speed.

Can CLS be completely eliminated?

Achieving zero CLS is extremely difficult due to dynamic content like ads and embeds. A score below 0.1 is considered good and is the target for most production sites.

Does Core Web Vitals affect SEO on all devices?

Yes, Google uses Core Web Vitals as a ranking signal for both mobile and desktop search results. Mobile metrics are given slightly more weight due to mobile-first indexing.

How often should I monitor Core Web Vitals?

Monitor continuously using a RUM solution. At minimum, check your Google Search Console Core Web Vitals report weekly to catch regressions early.

Does Doda Browser provide Core Web Vitals data?

Doda Browser includes built-in developer tools that surface LCP and CLS metrics during page inspection. Future versions will include a dedicated performance panel.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro