当用户想要优化 Core Web Vitals(核心网页指标),修复 LCP、INP、CLS 问题,或提及 CWV、LCP、INP、CLS 等关键词时使用。
Guides optimization of Core Web Vitals (CWV)—Google's user experience metrics that affect search ranking. CWV are confirmed ranking factors for mobile and desktop.
When invoking: On first use, if helpful, open with 1–2 sentences on what this skill covers and why it matters, then provide the main output. On subsequent use or when the user asks to skip, go directly to the main output.
MetricTargetGoodNeeds ImprovementPoorLCP≤2.5s≤2.5s2.5–4.0s>4.0sINP≤200ms≤200ms200–500ms>500msCLS<0.1≤0.10.1–0.25>0.25
Source: Google Page Experience
Check for project context first: If .claude/project-context.md or .cursor/project-context.md exists, read it for site URL.
Identify:
LCP measures the time until the largest content element (image, video, or text block) is visible.
CauseFixSlow server responseReduce TTFB; use CDN; optimize serverRender-blocking resourcesDefer non-critical CSS/JS; inline critical CSSLarge imagesWebP/AVIF; compress; width/ height to prevent CLS; see image-optimization****Client-side renderingSSR/SSG for above-fold content; see rendering-strategies****Third-party scriptsLoad async; defer non-critical
LCP candidates: Hero image, large text block, video poster. Ensure above-fold images use loading="eager" (default); never lazy-load LCP.
INP measures responsiveness—time from user interaction to next paint. Replaced FID in March 2024.
CauseFixLong-running JSBreak tasks >50ms; use requestIdleCallback; Web WorkersHeavy event handlersDebounce/throttle; defer non-critical workMain thread blockingReduce third-party scripts; defer non-critical JSLayout thrashingBatch DOM reads/writes; avoid forced reflows
CLS measures unexpected layout shifts.
CauseFixImages without dimensionsAlways set width and height attributesDynamic contentReserve space for ads, embeds; use min-heightWeb fontsfont-display: optional or swap; preload critical fontsAnimationsUse transform instead of top/ left/ width
Reserve space: For images, ads, embeds—define dimensions before load. Avoid inserting content above existing content without reserved space.
ToolUseGSCCore Web Vitals report; URL grouping; field dataPageSpeed InsightsLab + field data; mobile + desktopChrome DevToolsPerformance panel; LCP element; layout shift overlay