Core Web Vitals: Measure and Improve Web Performance
Why Core Web Vitals Matter
You've built a fast website, but users still complain about slow loading or janky interactions. Search engines may also rank you lower if your Core Web Vitals (CWV) scores are poor. CWV are a set of metrics that Google uses to quantify user experience: Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). In 2021, Google made these metrics a ranking factor, so ignoring them can hurt your SEO and user retention.
This guide explains how to measure each metric, identify common issues, and apply practical fixes. We'll focus on actionable steps you can take today, without diving into every edge case.
Understanding the Three Core Web Vitals
Before optimizing, know what each metric measures and its thresholds.
| Metric | Measures | Good | Needs Improvement | Poor |
|---|---|---|---|---|
| LCP | Loading performance: time until the largest content element is rendered. | ≤ 2.5s | 2.5s – 4.0s | > 4.0s |
| FID | Interactivity: time from first user interaction to browser response. | ≤ 100ms | 100ms – 300ms | > 300ms |
| CLS | Visual stability: unexpected layout shifts. | ≤ 0.1 | 0.1 – 0.25 | > 0.25 |
Note: FID is being replaced by Interaction to Next Paint (INP) in March 2024, but the optimization principles are similar. We'll focus on FID here as it's still widely referenced.
How to Measure Core Web Vitals
You need both lab and field data. Lab data (synthetic) helps debug; field data (real users) shows actual performance.
Lab Tools
- Lighthouse in Chrome DevTools: Run audits for performance, accessibility, and SEO. It reports LCP, CLS, and TBT (a proxy for FID).
- WebPageTest: Advanced testing with filmstrips and waterfall charts.
- PageSpeed Insights: Combines lab and field data (if available).
Field Tools
- Chrome User Experience Report (CrUX): Public dataset of real-user metrics. Access via PageSpeed Insights or BigQuery.
- web-vitals JavaScript library: Collect real-user metrics in your analytics.
- Search Console Core Web Vitals report: Shows URL groups with issues.
Start with PageSpeed Insights to get a quick overview, then use Lighthouse for detailed diagnostics.
Improving Largest Contentful Paint (LCP)
LCP often suffers from slow server response, render-blocking resources, or unoptimized images. Follow these steps:
- Optimize server response time: Use caching, a CDN, and efficient backend code. Aim for Time to First Byte (TTFB) under 0.8s.
- Eliminate render-blocking resources: Inline critical CSS, defer non-critical CSS and JavaScript. Use
asyncordeferfor scripts. - Optimize images: Compress images, use modern formats (WebP, AVIF), and implement responsive images with
srcset. For the LCP image, preload it with<link rel="preload">. - Use a CDN: Serve static assets from edge locations.
- Cache assets: Set long cache lifetimes for static resources.
Example: Preload the LCP image and set explicit dimensions to avoid layout shifts.
<link rel="preload" as="image" href="/hero.webp" imagesrcset="/hero-480.webp 480w, /hero-800.webp 800w" imagesizes="(max-width: 600px) 480px, 800px">
<img src="/hero.webp" srcset="/hero-480.webp 480w, /hero-800.webp 800w" sizes="(max-width: 600px) 480px, 800px" alt="Hero" width="800" height="600">
Improving First Input Delay (FID)
FID measures responsiveness. Long JavaScript tasks block the main thread, delaying interactions. To improve FID:
- Break up long tasks: Use
setTimeoutorrequestIdleCallbackto yield to the main thread. - Minimize main-thread work: Reduce JavaScript execution time, avoid large bundles, and use code splitting.
- Optimize event handlers: Debounce or throttle expensive handlers.
- Use web workers for CPU-intensive tasks.
- Avoid large third-party scripts: Audit and remove unnecessary scripts.
Tools like Lighthouse flag long tasks. Use the Performance panel in Chrome DevTools to identify them.
Improving Cumulative Layout Shift (CLS)
CLS measures visual stability. Layout shifts occur when elements change position unexpectedly. Common causes and fixes:
- Images without dimensions: Always set
widthandheightattributes or use CSSaspect-ratio. - Ads, embeds, and iframes: Reserve space with a placeholder or set fixed dimensions.
- Dynamic content: Avoid inserting content above existing content unless in response to user interaction.
- Web fonts: Use
font-display: swapand preload fonts to avoid invisible text (FOIT) and layout shifts. - Animations: Prefer CSS
transformandopacityfor animations, as they don't trigger layout.
Test with the Layout Instability API in DevTools or use the web-vitals library to log CLS in the field.
Practical Workflow for Continuous Monitoring
Optimization is not a one-time task. Set up monitoring:
- Instrument your site with the
web-vitalslibrary and send metrics to your analytics platform. - Set up alerts for when metrics exceed thresholds.
- Regularly run Lighthouse in CI/CD to catch regressions.
- Use Search Console to monitor field data trends.
Remember that field data is what matters for ranking. Lab data helps you debug, but always validate with real users.
FAQ
What are the current thresholds for Core Web Vitals?
As of 2023, the thresholds are: LCP good ≤2.5s, needs improvement 2.5s–4.0s, poor >4.0s; FID good ≤100ms, needs improvement 100ms–300ms, poor >300ms; CLS good ≤0.1, needs improvement 0.1–0.25, poor >0.25. Note that FID is being replaced by INP in 2024.
How often should I measure Core Web Vitals?
Monitor field data continuously via analytics, and run lab tests (e.g., Lighthouse) on every deployment or at least weekly. Major changes should trigger a new audit.
Can I improve Core Web Vitals without a developer?
Some fixes like compressing images or enabling caching can be done via plugins or hosting settings. However, deeper optimizations (e.g., code splitting, critical CSS) typically require development work.
Ready to optimize your images for better LCP? Try our free Image Compressor to reduce file sizes without losing quality.