web-performance
Use when the user asks to improve Core Web Vitals, a slow LCP (e.g. 4 seconds), INP or CLS problems, long tasks, Lighthouse scores, field vs lab data, CrUX or…
by j4flmao★ 47 GitHub stars
Install web-performance in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Web Performance: Core Web Vitals
Purpose
Core Web Vitals are Google's user-centric metrics, evaluated at the 75th percentile of real-user (field) page loads: LCP (loading), INP (responsiveness; replaced FID in March 2024) and CLS (visual stability). This skill measures them correctly and applies the fixes that move each metric.
Agent Protocol
Trigger
"core web vitals", "LCP", "INP", "CLS", "lighthouse", "PageSpeed Insights", "CrUX", "long task", "slow page", "layout shift".
Input Context
- Field data (CrUX/PageSpeed Insights/RUM) per page template and device class.
- Lab traces (Chrome DevTools Performance panel, Lighthouse).
- Stack (SSR/SPA, framework, CDN) and third-party scripts.
Output Artifact
Prioritised findings per metric with code/config fixes and expected effect.
Response Format
Page/template: {url pattern} Device: {mobile|desktop}
Metric: {LCP|INP|CLS} p75={value} target={threshold}
Breakdown: {sub-parts}
Root cause: {...}
Fix: {code/config}
Verify: {lab check + field metric to watch}
Thresholds (p75)
| Metric | Good | Needs improvement | Poor |
|---|---|---|---|
| LCP | ≤ 2.5 s | ≤ 4.0 s | > 4.0 s |
| INP | ≤ 200 ms | ≤ 500 ms | > 500 ms |
| CLS | ≤ 0.1 | ≤ 0.25 | > 0.25 |
Field data decides; Lighthouse is a lab diagnostic (it cannot measure INP — use Total Blocking Time as a lab proxy).
Measure in the Field
import { onLCP, onINP, onCLS, type Metric } from 'web-vitals/attribution';
function send(metric: Metric) {
const body = JSON.stringify({
name: metric.name,
value: metric.value,
rating: metric.rating,
id: metric.id,
page: location.pathname,
attribution: metric.attribution, // e.g. LCP element/subparts, INP target + long frames
});
if (!navigator.sendBeacon('/rum', body)) {
void fetch('/rum', { method: 'POST', body, keepalive: true });
}
}
onLCP(send);
onINP(send);
onCLS(send);
LCP
Break LCP into sub-parts (the web-vitals attribution build reports them): TTFB → resource load delay → resource load duration → element render delay.
| Sub-part too large | Fix |
|---|---|
| TTFB | CDN/edge caching, avoid redirects, stream HTML, faster server/DB |
| Load delay | Make the LCP image discoverable in HTML (no JS-injected or CSS background hero); fetchpriority="high"; never loading="lazy" on it |
| Load duration | Right-size with srcset/sizes, AVIF/WebP, preconnect to image CDN |
| Render delay | Remove render-blocking CSS/JS, avoid client-only rendering of hero, font font-display |
<link rel="preconnect" href="https://img.example-cdn.com" crossorigin>
<img
src="https://img.example-cdn.com/hero-1200.avif"
srcset="https://img.example-cdn.com/hero-800.avif 800w, https://img.example-cdn.com/hero-1200.avif 1200w"
sizes="100vw" width="1200" height="600" alt="Product hero"
fetchpriority="high">
Use <link rel="preload" as="image" imagesrcset=... imagesizes=...> only when the image cannot be in the initial HTML.
INP
INP = input delay + processing time + presentation delay for the slowest interactions (roughly the worst, ignoring outliers on pages with many interactions).
- Break long tasks (> 50 ms). Yield to the main thread between chunks:
function yieldToMain(): Promise<void> {
const s = (globalThis as { scheduler?: { yield?: () => Promise<void> } }).scheduler;
if (s?.yield) return s.yield(); // continuation keeps priority where supported
return new Promise((resolve) => setTimeout(resolve, 0));
}
export async function processItems<T>(items: T[], work: (item: T) => void): Promise<void> {
let deadline = performance.now() + 50;
for (const item of items) {
work(item);
if (performance.now() > deadline) {
await yieldToMain();
deadline = performance.now() + 50;
}
}
}
- In event handlers, update the UI first, defer non-visual work (analytics, saving) until after the next paint.
- Avoid layout thrashing (reading layout after writing styles in a loop).
- Large DOM (thousands of nodes) inflates presentation delay: virtualise long lists, use
content-visibility: autofor offscreen sections. - In React use transitions for expensive re-renders; move CPU-heavy work to Web Workers.
- Audit third-party scripts with the Long Animation Frames API (
PerformanceObservertypelong-animation-frame) attribution.
CLS
| Cause | Fix |
|---|---|
| Images/video/iframes without dimensions | width/height attributes or aspect-ratio |
| Ads/embeds injected late | Reserve space with min-height per slot |
| Web fonts swapping metrics | font-display: optional or metric-matched fallbacks (size-adjust, ascent-override) |
| Content inserted above existing content | Insert below, or on user interaction (shifts within 500 ms of input are excluded) |
Animating top/height |
Animate transform/opacity |
Ensure pages are eligible for the back/forward cache (no
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the web-performance skill do?
Use when the user asks to improve Core Web Vitals, a slow LCP (e.g. 4 seconds), INP or CLS problems, long tasks, Lighthouse scores, field vs lab data, CrUX or the web-vitals library. Produces a diagnosis and fixes for LCP, INP and CLS based on field data. Not for bundle architecture inside a framework (use frontend-performance).
How do I install the web-performance skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the web-performance skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…