惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
B
Blog
博客园_首页
博客园 - 司徒正美
有赞技术团队
有赞技术团队
博客园 - 聂微东
I
InfoQ
美团技术团队
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to Measure and Improve Core Web Vitals in Under 30 Mi...
Kui Luo · 2026-05-28 · via DEV Community

Kui Luo

Core Web Vitals directly impact your search rankings and user experience. Google confirmed in 2024 that sites meeting all three thresholds see an average 15-20% boost in organic traffic.

The Three Metrics That Matter

Metric What It Measures Good Needs Work Poor
LCP (Largest Contentful Paint) Loading speed of main content ≤ 2.5s 2.5s - 4.0s > 4.0s
INP (Interaction to Next Paint) Responsiveness to user input ≤ 200ms 200ms - 500ms > 500ms
CLS (Cumulative Layout Shift) Visual stability during load ≤ 0.1 0.1 - 0.25 > 0.25

Note: INP replaced FID as the responsiveness metric in March 2024.

Step 1: Get Your Baseline Numbers (5 minutes)

Open Chrome DevTools on any page and run a Lighthouse audit. Go to the Performance tab and look for the Core Web Vitals section in the diagnostics panel.

For real-user data, check your search console dashboard. It shows field data aggregated from actual Chrome users over the past 28 days. This is more reliable than synthetic lab tests because it reflects real network conditions and device capabilities.

If you want programmatic access, the Web Vitals JavaScript library collects metrics from real users:

import { onLCP, onINP, onCLS } from 'web-vitals';

onLCP(console.log);
onINP(console.log);
onCLS(console.log);

Enter fullscreen mode Exit fullscreen mode

Send these to your analytics endpoint to track improvements over time.

Step 2: Fix LCP Issues (10 minutes)

The most common LCP bottleneck is a slow hero image. Here are the fixes that move the needle the most:

  • Preload the LCP image. Add a <link rel="preload"> tag in your HTML head for the above-the-fold image. This tells the browser to start downloading it immediately instead of waiting for CSS to discover it.

  • Use modern image formats. Converting PNG/JPEG to WebP or AVIF typically reduces file size by 30-50% with minimal quality loss. Most browsers support WebP now — AVIF support is at 93% and growing.

  • Set explicit width and height on images. Without dimensions, the browser cannot reserve space, causing layout shifts that cascade into slower rendering.

  • Eliminate render-blocking resources. Move critical CSS inline and defer non-critical stylesheets. Scripts should use defer or async attributes.

A practical approach: serve hero images at exactly the display size. Serving a 2400px image for a 600px display slot wastes bandwidth and decode time. Use srcset with multiple resolutions.

Step 3: Reduce INP (8 minutes)

INP measures how quickly your page responds to every click, tap, or key interaction. High INP usually comes from JavaScript blocking the main thread.

  • Break up long tasks. Any task over 50ms is a problem. Use requestIdleCallback or scheduler.yield() to split work into smaller chunks that let the browser handle user input between them.

  • Debounce expensive event handlers. Input and scroll events fire at high frequency. Throttle handlers to at most once per frame using requestAnimationFrame.

  • Lazy load non-critical JavaScript. Code that handles modals, analytics, or below-the-fold features should load after the main content is interactive.

The quickest win: open DevTools Performance panel, record a click interaction, and look for yellow "Long Task" markers. Each one is a candidate for splitting.

Step 4: Eliminate CLS (7 minutes)

Layout shifts happen when elements move after initial render. Common causes and fixes:

  • Images and embeds without dimensions. Always set width and height attributes. The browser calculates aspect ratio from these and reserves space before the image loads.

  • Late-loading web fonts. Use font-display: optional to prevent invisible text from causing shifts when fonts load. Better yet, preload critical fonts with <link rel="preload" as="font">.

  • Dynamically injected content. Ads, banners, or toasts that push content down. Reserve fixed-height containers for these elements, or use position: absolute so they overlay instead of shifting layout.

  • Client-side rendering without skeletons. If your framework renders content on the client, show skeleton placeholders that match the final layout dimensions. This prevents content from jumping into view.

Quick Verification

After making changes, run Lighthouse again and compare the numbers. Focus on the mobile score — mobile devices have slower CPUs and networks, so mobile scores are typically 20-40% lower than desktop.

For ongoing monitoring, set up automated Lighthouse CI in your deployment pipeline. Track scores on every pull request to catch regressions before they reach production.

The entire audit-and-fix cycle should take under 30 minutes for most sites. The search ranking and user experience improvements compound over weeks, making this one of the highest-ROI technical improvements you can make.