Core Web Vitals: How to Get a Perfect Score in 2024
Core Web Vitals: Achieving a Perfect Score in 2024
Google's Core Web Vitals became official ranking factors in 2021, and their importance has only grown. Pages with excellent Core Web Vitals scores consistently rank higher than comparable pages with poor scores.
What Are Core Web Vitals?
Core Web Vitals are a set of specific metrics that measure the user experience on your website:
1. Largest Contentful Paint (LCP)
**What it measures**: Loading performance — how long until the largest content element is visible
**Good score**: Under 2.5 seconds
**Poor score**: Over 4.0 seconds
LCP is usually your hero image, large heading, or video thumbnail.
2. Interaction to Next Paint (INP)
**What it measures**: Interactivity — how quickly the page responds to user interactions
**Good score**: Under 200 milliseconds
**Poor score**: Over 500 milliseconds
Note: INP replaced FID (First Input Delay) in March 2024.
3. Cumulative Layout Shift (CLS)
**What it measures**: Visual stability — how much the page layout shifts unexpectedly
**Good score**: Under 0.1
**Poor score**: Over 0.25
CLS is that annoying experience where you go to click something and it moves just before you click.
Optimizing LCP
Eliminate Render-Blocking Resources
Render-blocking JavaScript and CSS delay when the browser can first paint content.
<!-- Before: blocks rendering -->
<link rel="stylesheet" href="styles.css">
<script src="analytics.js"></script>
<!-- After: non-blocking -->
<link rel="preload" href="critical.css" as="style">
<script defer src="analytics.js"></script>
Preload the LCP Image
<link rel="preload" as="image" href="/hero-image.webp" fetchpriority="high">
Use Modern Image Formats
WebP images are 25-34% smaller than JPEG. AVIF is even smaller (50% smaller than JPEG).
<picture>
<source type="image/avif" srcset="hero.avif">
<source type="image/webp" srcset="hero.webp">
<img src="hero.jpg" alt="Hero image" width="1200" height="600" fetchpriority="high">
</picture>
Use a CDN
A Content Delivery Network serves assets from servers closest to the user. This alone can reduce LCP by 50-200ms.
**Recommended**: Cloudflare (free tier available), AWS CloudFront, Fastly
Optimizing INP
Reduce JavaScript Execution Time
// Before: heavy synchronous operation
function processData(items) {
return items.map(item => heavyComputation(item));
}
// After: yield to browser between chunks
async function processData(items) {
const results = [];
for (const item of items) {
results.push(heavyComputation(item));
await yieldToMain(); // allows browser to handle user input
}
return results;
}
function yieldToMain() {
return new Promise(resolve => setTimeout(resolve, 0));
}
Implement the Event Callbacks Pattern
Use event delegation and optimize event handlers to be as fast as possible.
Optimizing CLS
Always Size Images Explicitly
<!-- Without dimensions: causes layout shift -->
<img src="photo.jpg" alt="Photo">
<!-- With dimensions: reserves space -->
<img src="photo.jpg" alt="Photo" width="800" height="600">
Reserve Space for Ads
.ad-container {
min-height: 250px; /* Reserve minimum ad space */
width: 100%;
}
Use font-display: swap for Web Fonts
@font-face {
font-family: 'MyFont';
src: url('font.woff2') format('woff2');
font-display: swap; /* Show fallback font immediately */
}
Tools for Measuring Core Web Vitals
1. **Google Search Console**: Shows real-world data for your site
2. **PageSpeed Insights**: Combines lab and field data
3. **Chrome User Experience Report (CrUX)**: Large dataset of real user metrics
4. **Web Vitals extension**: Measure in real-time while browsing
5. **Lighthouse**: Detailed lab-based analysis
A Systematic Approach
1. Start with Google Search Console > Core Web Vitals report
2. Identify which pages have "Poor" or "Needs Improvement" status
3. Run those pages through PageSpeed Insights
4. Prioritize issues by impact × ease of fix
5. Implement fixes, then validate with PageSpeed Insights
6. Wait 28 days for field data to update in Search Console
Consistent improvement in Core Web Vitals directly correlates with improved rankings, lower bounce rates, and higher conversion rates.