Skip to main content

Page Speed & Core Web Vitals

Page speed and Core Web Vitals (CWV) are both user experience metrics and ranking signals. Google uses CWV as a ranking factor, with LCP (loading), INP (interactivity), and CLS (visual stability) as the key metrics.

Learning Focus

After this lesson you can optimize LCP, INP, and CLS through image compression, JavaScript reduction, CSS optimization, and server response tuning to meet Google's CWV thresholds.

This lesson covers the seven optimization areas (leaves 3.5.1–3.5.7): LCP optimization, INP optimization, CLS optimization, image optimization, JavaScript reduction, CSS optimization, and server response optimization.

Why This Matters

Core Concept
  • CWV is a confirmed ranking signal. Poor CWV can hold back pages that would otherwise rank well.
  • Speed affects conversion rates: a 1-second delay in page load can reduce conversions by 2-5%.
  • CWV affects crawl efficiency: Googlebot may allocate less crawl budget to slower sites.

LCP Optimization

Largest Contentful Paint (LCP) measures the time it takes for the largest content element (image, video, or block-level text) to become visible. Target: ≤ 2.5 seconds.

Common LCP elements:

Element TypeCommon Cause of Poor LCPOptimization
Hero imageLarge, unoptimized imageCompress, resize, use next-gen formats (WebP, AVIF), lazy-load below-fold images
Heading/text blockSlow-rendered font or CSSInline critical CSS, preload fonts, reduce render-blocking resources
Video posterLarge poster imageOptimize poster image, consider removing autoplay
Background imageCSS background-image with large fileOptimize, consider replacing with <img> tag for loading control

LCP optimization techniques:

TechniqueTypical ImprovementEffort
Optimize and compress images0.3-1.0sLow
Use a CDN with edge caching0.2-0.5sMedium
Remove render-blocking resources0.3-0.8sMedium
Preload LCP image0.1-0.3sLow
Enable text compression (Brotli/Gzip)0.1-0.3sLow
Upgrade hosting/server infrastructure0.3-1.0sMedium-High
Implement critical CSS0.2-0.5sMedium

LCP diagnosis:

  • Use Lighthouse or PageSpeed Insights: the LCP section shows the element and recommended fixes.
  • CrUX (Chrome User Experience Report): shows actual LCP from real users.
  • GSC CWV report: identifies URL groups with poor LCP.

INP Optimization

Interaction to Next Paint (INP) measures the responsiveness of a page to user interactions. Target: ≤ 200 milliseconds.

What INP measures:

  • The time from a user interaction (click, tap, key press) to the next visual update.
  • Longer INP means the page feels laggy or unresponsive to user input.

Common causes of poor INP:

CauseExampleOptimization
Long main thread tasksHeavy JavaScript processingBreak tasks into smaller chunks (setTimeout, requestIdleCallback)
Complex event handlersAttaching slow logic to every click eventDebounce, throttle, optimize handler code
Third-party script blockingAnalytics, chat widgets, ads loading on the main threadDefer non-critical third-party scripts, use web workers
Slow DOM updatesRe-rendering large sections of the page on interactionVirtual DOM, targeted DOM updates
Large JS bundlesAll JavaScript loaded and executed before interactionCode-splitting, lazy-load non-critical JS

INP diagnosis:

  • Lighthouse now includes INP measurement (experimental).
  • PageSpeed Insights shows INP from lab data.
  • Web Vitals extension or Chrome DevTools Performance panel for real-user measurement.

CLS Optimization

Cumulative Layout Shift (CLS) measures visual stability — how much the page layout shifts during load. Target: ≤ 0.1.

Common CLS causes:

CauseExampleCLS Impact
Images without dimensionsImages not specifying width/heightShift when image loads
Ads or embeds without reserved spaceAd insertion pushes content downSignificant shift
Dynamic content injected above existing contentBanner, cookie notice, newsletter popupShift when element appears
Web fonts causing layout shift (FOUT/FOIT)Fallback font then custom fontSmall but cumulative shift
Late-loading iframesYouTube embeds, social widgetsShift when iframe loads

CLS optimization techniques:

TechniqueTypical Improvement
Set explicit width/height on all images and video elementsEliminates most CLS from images
Reserve ad slot dimensionsPrevents ad-related shifts
Use font-display: optional or font-display: swap with size-adjustReduces font-related shifts
Avoid inserting content above existing contentUse push notifications reserved space
Set dimensions on iframesPrevents embed-related shifts

CLS diagnosis:

  • Lighthouse CLS section: shows the specific elements that caused shifts.
  • PageSpeed Insights: highlights cumulative layout shift sources.
  • Chrome DevTools: experience the page load with "Layout Shift" recording enabled.

Image Optimization

Images are often the largest resources on a page and a primary contributor to both LCP and page weight.

Image optimization principles:

PrincipleImplementation
Next-gen formatsUse WebP or AVIF instead of JPEG/PNG for all new images
Responsive imagesUse srcset to serve different sizes for different viewports
CompressionUse lossy compression with minimal visible quality loss (80-85% quality is usually optimal)
Lazy loadingLoad below-fold images only when they approach the viewport
Proper dimensionsSet width/height attributes to prevent CLS
CDN deliveryServe images from a CDN with edge caching

Image optimization techniques by impact:

TechniqueImpact on page weightTypical Improvement
Convert to WebP/AVIF25-35% reductionSignificant
Compress (lossy)30-50% reductionSignificant
Serve correct dimensions40-70% reductionSignificant
Lazy load below-foldVariable (depends on page scroll depth)Moderate
Use next-gen format (AVIF)50%+ reduction vs JPEGVery significant

Image optimization check:

  • Use Lighthouse: it shows potentially optimizable images.
  • Use PageSpeed Insights image optimization section.
  • Use tools like Squoosh, ImageOptim, or ShortPixel for compression.

JavaScript Reduction

Excessive or poorly optimized JavaScript can increase LCP, INP, and total page weight.

JavaScript optimization techniques:

TechniqueImplementationImpact
Code-splittingLoad only the JavaScript needed for the current pageReduces initial bundle size
Tree-shakingRemove unused JavaScript codeReduces bundle size
Lazy-load non-critical JSDefer JavaScript that is not needed for initial renderImproves LCP
Async/defer for non-critical scriptsasync for independent scripts, defer for ordered scriptsPrevents render-blocking
Remove unused JavaScriptAudit third-party scripts for value vs performance costVariable
Use ES modulesNative browser module loading for modern browsersBetter caching and dependency management

JavaScript auditing tools:

  • Lighthouse: JavaScript execution time section.
  • Coverage tab in Chrome DevTools: shows used vs unused JavaScript.
  • Bundle analyzers (webpack-bundle-analyzer, source-map-explorer): identify large dependencies.

Measurement: After JS optimization, verify that core functionality still works and that no regression occurs in tracking, forms, or dynamic content.

CSS Optimization

CSS optimization reduces render-blocking stylesheets and stylesheet size.

CSS optimization techniques:

TechniqueImplementationImpact
Critical CSS inlineInline CSS needed for above-fold content, defer the restImproves LCP by reducing render-blocking
MinificationRemove whitespace, comments, and unnecessary charactersReduces file size by 20-40%
Remove unused CSSAudit and remove CSS rules that do not match any HTML elementCan significantly reduce CSS file size
Reduce specificitySimplify selectors to improve rendering performanceMarginal impact on modern browsers
Use CSS variablesReduce repetition in stylesheetsMaintainability improvement

CSS auditing tools:

  • Lighthouse: Reduce unused CSS warnings.
  • Coverage tab in Chrome DevTools: shows used vs unused CSS.
  • PurgeCSS or UnCSS for removing unused CSS in build process.

Server Response Optimization

Server response time affects Time to First Byte (TTFB), which contributes to LCP and overall page speed.

Server response optimization techniques:

TechniqueImplementationTypical Improvement
CachingBrowser caching, CDN caching, server-level cachingSignificant (0.3-1.0s)
CDNMove content closer to users geographically0.2-0.8s
PHP/application optimizationOpcode caching, database query optimization0.1-0.5s
HTTP/2 or HTTP/3Multiplexed connections reduce latency0.1-0.3s
Brotli compressionBetter compression ratio than Gzip10-20% smaller transfers
Dedicated/upgraded hostingMove from shared to dedicated or upgraded plan0.2-1.0s

TTFB targets:

  • Good: < 200ms
  • Needs improvement: 200-500ms
  • Poor: > 500ms

Server response diagnosis:

  • PageSpeed Insights TTFB section.
  • WebPageTest: detailed server response timing.
  • Server monitoring tools (New Relic, DataDog): identify slow database queries or application code.

Workflow

  1. Measure baseline: Run PageSpeed Insights for desktop and mobile on 10 representative pages.
  2. Review CWV report in GSC: Identify URL groups with poor CWV.
  3. Prioritize fixes: Start with the highest-traffic pages with the worst metrics.
  4. Optimize images: Convert to WebP/AVIF, compress, set dimensions, add lazy loading.
  5. Optimize JavaScript: Code-split, lazy load, async/defer, remove unused.
  6. Optimize CSS: Inline critical CSS, minify, remove unused.
  7. Optimize server: Improve caching, CDN, compression, hosting.
  8. Re-measure: Verify improvement after each change.
  9. Monitor: Set up CWV monitoring to detect regressions.

Common Mistakes

warning

Optimizing for lab data only: Lighthouse and PageSpeed Insights are lab data. Always check CrUX (real-user data) for the full picture.

  • Over-optimizing images: Aggressive compression can harm image quality. Balance file size and visual quality.
  • Implementing critical CSS without testing: Incorrect critical CSS can break page rendering. Test thoroughly.
  • Ignoring third-party script impact: A single heavy third-party script (chat widget, analytics) can undo all other speed optimizations.
  • Not measuring before and after: Without measurement, you cannot confirm the optimization worked.

Checklist

  • LCP is ≤ 2.5s for all page groups (check GSC CWV report).
  • INP is ≤ 200ms (if available in your CWV report).
  • CLS is ≤ 0.1 for all page groups.
  • All images use next-gen formats (WebP/AVIF) with compression.
  • Images have explicit width/height attributes.
  • Below-fold images use lazy loading.
  • Critical CSS is inlined (or plan to implement).
  • JavaScript is code-split and non-critical scripts are lazy loaded.
  • Server response (TTFB) is < 200ms.
  • CDN is configured.
  • CWV is monitored with alerting for regression.

What's Next

References