LESSON 1 โฑ๏ธ 12 min read

Understanding Core Web Vitals

What Are Core Web Vitals?

Core Web Vitals are Google's metrics for measuring real-world user experience on websites. They directly impact your SEO rankings and user satisfaction.

The Three Core Metrics

MetricFull NameWhat It MeasuresGood Score
LCPLargest Contentful PaintLoading performance< 2.5s
INPInteraction to Next PaintInteractivity< 200ms
CLSCumulative Layout ShiftVisual stability< 0.1

Largest Contentful Paint (LCP)

LCP measures when the largest visible element finishes loading. This is usually:

  • Hero images
  • Large text blocks
  • Video thumbnails

Common LCP Issues

  1. Slow server response โ€“ TTFB over 600ms
  2. Render-blocking resources โ€“ CSS/JS blocking paint
  3. Slow resource load times โ€“ Large images, fonts
  4. Client-side rendering โ€“ JavaScript-dependent content

Quick LCP Wins

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

<!-- Preconnect to origins -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://cdn.example.com">

Interaction to Next Paint (INP)

INP replaced FID in 2024. It measures ALL interactions, not just the first:

  • Clicks
  • Key presses
  • Taps

Common INP Issues

  1. Heavy JavaScript execution โ€“ Long tasks blocking main thread
  2. Too many event listeners โ€“ Inefficient handlers
  3. Large DOM size โ€“ Slow DOM operations
  4. Third-party scripts โ€“ Analytics, chat widgets

Quick INP Wins

// Use passive event listeners
document.addEventListener('scroll', handler, { passive: true });

// Debounce expensive operations
function debounce(fn, delay) {
    let timeout;
    return (...args) => {
        clearTimeout(timeout);
        timeout = setTimeout(() => fn(...args), delay);
    };
}

Cumulative Layout Shift (CLS)

CLS measures unexpected layout shifts during page load.

Common CLS Causes

  1. Images without dimensions โ€“ No width/height
  2. Ads and embeds โ€“ Dynamic content insertion
  3. Web fonts โ€“ FOUT/FOIT causing reflow
  4. Dynamic content โ€“ JavaScript-inserted elements

Quick CLS Wins

<!-- Always set image dimensions -->
<img src="photo.jpg" width="800" height="600" alt="Photo">

<!-- Or use aspect-ratio CSS -->
<style>
.hero-image {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
}
</style>

Measuring Core Web Vitals

Lab Tools (Development)

ToolUse For
LighthouseManual audits in DevTools
PageSpeed InsightsDetailed recommendations
WebPageTestWaterfall analysis

Field Tools (Real Users)

ToolUse For
Chrome UX Report (CrUX)Aggregated real user data
Search ConsoleYour site's field data
web-vitals.jsCustom monitoring

Using Lighthouse

# Install CLI
npm install -g lighthouse

# Run audit
lighthouse https://example.com --view

# Mobile + Desktop
lighthouse https://example.com --preset=desktop --view
lighthouse https://example.com --form-factor=mobile --view
Lab vs Field Data: Lab tests are consistent but may not reflect real user experience. Field data shows actual performance but varies by user device/network. Both matter!

WordPress-Specific Performance Issues

Common WordPress performance problems:

IssueImpactSolution
Too many pluginsSlow load, bloatAudit and remove
Heavy themeLarge CSS/JSChoose lightweight theme
No cachingServer strainAdd caching plugin
Unoptimized imagesSlow LCPCompress and resize
Database bloatSlow queriesCleanup and optimize

Next Steps

In the next lesson, we'll implement caching strategies at multiple levels.

๐ŸŽฏ Lesson Complete! You understand Core Web Vitals and how to measure them.