Improving Google Lighthouse Scores: Core Web Vitals (LCP, CLS, INP)0%

Improving Google Lighthouse Scores: Core Web Vitals (LCP, CLS, INP)

Advanced15 min readUpdated: 2026-09-10
Study Materials

Improving Google Lighthouse Scores: Core Web Vitals (LCP, CLS, INP)

Imagine entering a bank to deposit cash. If the main entrance glass door is stuck and takes 10 seconds to open (LCP), you get frustrated. Once inside, if the deposit slip countertop suddenly jumps two feet to the left right as your pen touches the paper (CLS), you scribble an accidental error on your cheque. And when you finally click the service bell and wait 5 seconds before anyone even looks up (INP), you leave with a terrible impression.

In 2020, Google officially made Core Web Vitals an organic search engine ranking signal. If your website scores poorly on Google Lighthouse, your search rankings plunge and bounce rates skyrocket. While many developers assume performance is purely a backend or JavaScript issue, over 60% of Core Web Vitals penalties are directly caused by unoptimized CSS and font-loading patterns!


1. The Big 3 Core Web Vitals Explained

Visual Architecture Blueprint
+-------------------------------------------------------------------------+
|                  THE 3 GOOGLE CORE WEB VITALS BENCHMARKS                |
+-------------------------------------------------------------------------+

  1. LCP (Largest Contentful Paint)   Target: <= 2.5 seconds
     Measures PERCEIVED LOADING SPEED.
     When does the largest headline or hero banner image finish painting?

  2. CLS (Cumulative Layout Shift)    Target: <= 0.1
     Measures VISUAL STABILITY.
     Do buttons, banners, or paragraphs jump around as fonts and images load?

  3. INP (Interaction to Next Paint)  Target: <= 200 milliseconds
     Measures USER INTERACTION RESPONSIVENESS.
     When the user clicks a tab or menu, does the UI respond immediately?

2. Eliminating Font Layout Shift with font-display & size-adjust

When a custom Google Font (like Inter or Poppins) is loading, two disasters commonly occur:

  • FOIT (Flash of Invisible Text): The browser hides text completely for up to 3 seconds until the font file arrives.
  • FOUT (Flash of Unstyled Text): The browser shows Arial first, and when Poppins arrives, the text size differences cause the entire article to jump, racking up heavy CLS penalties!

The Modern Font Solution:

CSS
/* 1. Ensure text is visible immediately using swap */
@font-face {
font-family: 'CustomPoppins';
src: url('/fonts/poppins.woff2') format('woff2');
font-weight: 700;
font-display: swap; /* Never hide text! Show fallback immediately */
}
 
/* 2. Micro-tune the fallback font so it takes the EXACT same space! */
@font-face {
font-family: 'FallbackArial';
src: local('Arial');
/* Harmonizes Arial's dimensions to match Poppins perfectly! */
size-adjust: 104.2%;
ascent-override: 95%;
descent-override: 25%;
line-gap-override: 0%;
}
 
body {
font-family: 'CustomPoppins', 'FallbackArial', sans-serif;
}

When the custom font finishes downloading, zero pixels shift on screen because the fallback font was mathematically calibrated to match its exact footprint!


3. Fixing Largest Contentful Paint (LCP) via CSS

The LCP element on most websites is either a large hero headline or a background hero image.

CSS Techniques to Accelerate LCP:

  1. 1
    Preload the Hero Font:
HTML
<link rel="preload" href="/fonts/poppins.woff2" as="font" type="font/woff2" crossorigin>
  1. 1
    Never Lazy-Load the LCP Image:
HTML
<!-- FORBIDDEN on the hero banner: loading="lazy" delays LCP by seconds! -->
<img src="hero.webp" fetchpriority="high" alt="Hero">
  1. 1
    Avoid Background Images for LCP Elements: The browser discovers <img> tags in HTML immediately via the Preload Scanner. However, an image declared via CSS background-image: url('hero.jpg') cannot be discovered until the CSS file is completely downloaded and parsed!

4. Conquering CLS: Aspect Ratio Reservation

Cumulative Layout Shift happens when elements render with zero initial height and suddenly pop open.

CSS
/* 1. Images & Videos: Always enforce aspect ratio */
img, video {
max-width: 100%;
height: auto;
aspect-ratio: 16 / 9; /* Reserves space BEFORE image bytes download! */
}
 
/* 2. Dynamic Banner Ads & Widgets */
.ad-slot-container {
min-height: 250px; /* Locks vertical space so content below never jumps */
background: #f1f5f9;
}

5. Do's and Don'ts of Core Web Vitals Optimization

CategoryDoDon't
Font DisplayAlways set font-display: swap on @font-face declarations.Allow text to remain completely invisible for seconds (FOIT).
Image ReservationUse aspect-ratio: 16 / 9 or explicit width and height attributes on images.Insert naked <img> tags with zero dimensional constraints, destroying CLS.
Hero GraphicsUse standard <img> with fetchpriority="high" for hero banners.Use CSS background-image for LCP heroes, hiding the asset from the HTML preload scanner.
AnimationsAnimate exclusively using transform and opacity.Animate top, left, width, or height, which triggers continuous layout recalculations and hurts INP.

6. Quick Revision Summary

Visual Architecture Blueprint
+-------------------------------------------------------------------------+
|                  CORE WEB VITALS OPTIMIZATION CHEAT SHEET               |
+-------------------------------------------------------------------------+

  1. LCP <= 2.5s:
     - Inline Critical CSS (<14KB).
     - Preload .woff2 fonts with crossorigin.
     - Use <img> with fetchpriority="high" for hero artwork.

  2. CLS <= 0.1:
     - img { aspect-ratio: 16/9; }
     - Reserve ad & widget container min-heights.
     - Calibrate fallback fonts with size-adjust.

  3. INP <= 200ms:
     - Animate with transform & opacity only.
     - Keep CSS selector specificity flat (BEM / @layer).

Multiple Choice Questions

1. Which Google Core Web Vital metric measures the visual stability of a webpage to prevent unexpected layout jumping?

A. First Input Delay (FID) B. Cumulative Layout Shift (CLS) C. Time to First Byte (TTFB) D. Total Blocking Time (TBT)

Answer: B Explanation: CLS (Cumulative Layout Shift) quantifies how often and how severely elements unexpectedly move on screen as fonts, images, and embeds load.

2. What does declaring font-display: swap; inside an @font-face block achieve?

A. It disables italic font variants B. It instructs the browser to render text immediately using a fallback system font, then swap in the web font once it finishes loading, eliminating invisible text (FOIT) C. It converts web fonts into SVG outlines D. It rotates fonts upside down

Answer: B Explanation: font-display: swap instructs the browser to immediately display fallback system text rather than waiting in the dark with blank invisible text (FOIT), ensuring immediate readability.

3. Why does declaring a hero banner image as an HTML <img> with fetchpriority="high" outperform a CSS background-image for LCP?

A. HTML tags are scanned and preloaded by the browser's fast C++ Preload Scanner before CSS files finish parsing B. CSS images cannot display high-resolution colors C. Background images are disabled on 4G networks D. fetchpriority only works inside JavaScript

Answer: A Explanation: The browser Preload Scanner discovers HTML <img> tags while downloading the HTML stream. CSS background-image references remain completely invisible to the browser until the entire stylesheet has downloaded and parsed.

4. How does size-adjust inside @font-face help eliminate Cumulative Layout Shift (CLS)?

A. It compresses the font file size B. It scales the glyph dimensions of the fallback system font so its physical footprint matches the incoming web font, preventing text reflow during font swap C. It automatically translates text into different languages D. It forces text to fit inside a single line

Answer: B Explanation: size-adjust scales fallback system fonts (like Arial) to match the exact physical proportions of custom web fonts (like Poppins), eliminating the layout jump when fonts swap.

5. To maintain responsive Interaction to Next Paint (INP <= 200ms), which CSS properties should be used for UI transitions and hover animations?

A. width and height B. transform and opacity C. margin-top and padding-left D. top and left

Answer: B Explanation: transform and opacity are executed on the GPU compositor thread without triggering layout reflows or repaints on the main thread, keeping the main thread free to respond to user interactions instantly.

Hands-On Practice Challenge: Google Lighthouse Core Web Vitals Studio

Experiment with this interactive performance telemetry station. Toggle image aspect ratio reservation and font display swap to watch the simulated Lighthouse Performance Score leap to 100!

Next Lesson

Project 1: Interactive Analytics Dashboard UI with Grid & Container Queries

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext