Back to Agent Skills
Frontend & Design
Core Web Vitals Optimization
Measure and optimize Core Web Vitals (LCP, INP, CLS) to improve user experience and search engine rankings.
Claude Code Cursor Copilot Windsurf Gemini CLI
Overview
Core Web Vitals are Google's key metrics for user experience: Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS). AI agents can analyze your code for performance bottlenecks and implement optimizations that improve these metrics directly.
Your AI agent can implement lazy loading for images and components, optimize critical rendering paths, add `fetchpriority="high"` to LCP elements, implement proper image dimensions to prevent CLS, defer non-critical JavaScript, and use `requestIdleCallback` for non-urgent work. These changes can dramatically improve your real-user metrics.
The `web-vitals` JavaScript library lets you measure these metrics in production. AI agents can set up Real User Monitoring (RUM) to track vitals, identify pages with poor scores, and systematically fix issues like render-blocking resources, unoptimized images, and layout shifts caused by dynamic content.
Your AI agent can implement lazy loading for images and components, optimize critical rendering paths, add `fetchpriority="high"` to LCP elements, implement proper image dimensions to prevent CLS, defer non-critical JavaScript, and use `requestIdleCallback` for non-urgent work. These changes can dramatically improve your real-user metrics.
The `web-vitals` JavaScript library lets you measure these metrics in production. AI agents can set up Real User Monitoring (RUM) to track vitals, identify pages with poor scores, and systematically fix issues like render-blocking resources, unoptimized images, and layout shifts caused by dynamic content.
Who Is This For?
- Frontend developers optimizing LCP by prioritizing critical resources
- Teams fixing CLS issues caused by dynamic content and ads
- Performance engineers implementing INP optimizations for interactive pages
- SEO teams improving search rankings through better Core Web Vitals
Installation
Setup for Claude Code
npm install web-vitals
Claude Code can analyze and optimize your code for CWV Configuration
// Measure Core Web Vitals
import { onLCP, onINP, onCLS } from "web-vitals";
onLCP(console.log);
onINP(console.log);
onCLS(console.log);
// Send to analytics
onLCP((metric) => {
fetch("/api/vitals", {
method: "POST",
body: JSON.stringify({ name: metric.name, value: metric.value }),
});
}); Explore AI Tools
Discover the best AI tools that complement your skills
Read AI & Design Articles
Tips and trends in the world of design and AI
Related Skills
Frontend & Design
Figma MCP Server
Bridge the gap between design and code by connecting Figma to your AI agent via MCP, enabling accurate design-to-code translation.
Claude Code Cursor
Frontend & Design Storybook Component Docs
Build, document, and visually test UI components in isolation using Storybook. AI agents can generate stories and catch visual regressions.
Claude Code Copilot Cursor
Frontend & Design Tailwind CSS IntelliSense
Get intelligent Tailwind class suggestions, autocompletions, and linting as you style components in your editor.
Copilot Cursor Windsurf