|
1 | 1 | --- |
2 | 2 | name: webperf-core-web-vitals |
3 | 3 | description: Intelligent Core Web Vitals analysis with automated workflows and decision trees. Measures LCP, CLS, INP with guided debugging that automatically determines follow-up analysis based on results. Includes workflows for LCP deep dive (5 phases), CLS investigation (loading vs interaction), INP debugging (latency breakdown + attribution), and cross-skill integration with loading, interaction, and media skills. Use when the user asks about Core Web Vitals, LCP optimization, layout shifts, or interaction responsiveness. Compatible with Chrome DevTools MCP. |
| 4 | +license: MIT |
| 5 | +metadata: |
| 6 | + author: Joan Leon | @nucliweb |
| 7 | + version: 1.0.0 |
| 8 | + mcp-server: chrome-devtools |
| 9 | + category: web-performance |
| 10 | + repository: https://github.com/nucliweb/webperf-snippets |
4 | 11 | --- |
5 | 12 |
|
6 | 13 | # WebPerf: Core Web Vitals |
7 | 14 |
|
8 | 15 | JavaScript snippets for measuring web performance in Chrome DevTools. Execute with `mcp__chrome-devtools__evaluate_script`, capture output with `mcp__chrome-devtools__get_console_message`. |
9 | 16 |
|
10 | | -## Available Snippets |
| 17 | +## Scripts |
11 | 18 |
|
12 | | -| Snippet | Description | File | |
13 | | -|---------|-------------|------| |
14 | | -| Cumulative Layout Shift (CLS) | Quick check for Cumulative Layout Shift, a Core Web Vital that measures visual stability | scripts/CLS.js | |
15 | | -| Interaction to Next Paint (INP) | Tracks Interaction to Next Paint, a Core Web Vital that measures responsiveness | scripts/INP.js | |
16 | | -| LCP Image Entropy | Checks if images qualify as LCP candidates based on their entropy (bits per pixel) | scripts/LCP-Image-Entropy.js | |
17 | | -| LCP Sub-Parts | Breaks down Largest Contentful Paint into its four phases to identify optimization opportunities | scripts/LCP-Sub-Parts.js | |
18 | | -| LCP Trail | Tracks every LCP candidate element during page load and highlights each one with a distinct pastel-c | scripts/LCP-Trail.js | |
19 | | -| LCP Video Candidate | Detects whether the LCP element is a <video> and audits the poster image configuration — the most co | scripts/LCP-Video-Candidate.js | |
20 | | -| Largest Contentful Paint (LCP) | Quick check for Largest Contentful Paint, a Core Web Vital that measures loading performance | scripts/LCP.js | |
| 19 | +- `scripts/CLS.js` — Cumulative Layout Shift (CLS) |
| 20 | +- `scripts/INP.js` — Interaction to Next Paint (INP) |
| 21 | +- `scripts/LCP-Image-Entropy.js` — LCP Image Entropy |
| 22 | +- `scripts/LCP-Sub-Parts.js` — LCP Sub-Parts |
| 23 | +- `scripts/LCP-Trail.js` — LCP Trail |
| 24 | +- `scripts/LCP-Video-Candidate.js` — LCP Video Candidate |
| 25 | +- `scripts/LCP.js` — Largest Contentful Paint (LCP) |
21 | 26 |
|
22 | | -## Execution with Chrome DevTools MCP |
23 | | - |
24 | | -``` |
25 | | -1. mcp__chrome-devtools__navigate_page → navigate to target URL |
26 | | -2. mcp__chrome-devtools__evaluate_script → run snippet code (read from scripts/ file) |
27 | | -3. mcp__chrome-devtools__get_console_message → capture console output |
28 | | -4. Interpret results using thresholds below, provide recommendations |
29 | | -``` |
| 27 | +Descriptions and thresholds: `references/snippets.md` |
30 | 28 |
|
31 | 29 | ## Common Workflows |
32 | 30 |
|
@@ -221,91 +219,9 @@ When multiple CWV metrics are poor, prioritize investigation: |
221 | 219 | 2. Run Interactions.js |
222 | 220 | 3. Check if shifts occur during/after interactions |
223 | 221 |
|
224 | | ---- |
225 | | - |
226 | | ---- |
227 | | - |
228 | | -## Cumulative Layout Shift (CLS) |
229 | | - |
230 | | -Quick check for Cumulative Layout Shift, a Core Web Vital that measures visual stability. CLS tracks how much the page layout shifts unexpectedly during its lifetime, providing a single score that represents the cumulative impact of all unexpected layout shifts. |
231 | | - |
232 | | -**Script:** `scripts/CLS.js` |
233 | | - |
234 | | -**Thresholds:** |
235 | | - |
236 | | -| Rating | Score | Meaning | |
237 | | -|--------|-------|---------| |
238 | | -| 🟢 Good | ≤ 0.1 | Stable, minimal shifting | |
239 | | -| 🟡 Needs Improvement | ≤ 0.25 | Noticeable shifting | |
240 | | -| 🔴 Poor | > 0.25 | Significant layout instability | |
241 | | - |
242 | | ---- |
243 | | - |
244 | | -## Interaction to Next Paint (INP) |
245 | | - |
246 | | -Tracks Interaction to Next Paint, a Core Web Vital that measures responsiveness. INP evaluates how quickly a page responds to user interactions throughout the entire page visit, replacing First Input Delay (FID) as a Core Web Vital in March 2024. |
247 | | - |
248 | | -**Script:** `scripts/INP.js` |
249 | | - |
250 | | -**Thresholds:** |
251 | | - |
252 | | -| Rating | Time | Meaning | |
253 | | -|--------|------|---------| |
254 | | -| 🟢 Good | ≤ 200ms | Responsive, feels instant | |
255 | | -| 🟡 Needs Improvement | ≤ 500ms | Noticeable delay | |
256 | | -| 🔴 Poor | > 500ms | Slow, frustrating experience | |
257 | | - |
258 | | ---- |
259 | | - |
260 | | -## LCP Image Entropy |
261 | | - |
262 | | -Checks if images qualify as LCP candidates based on their entropy (bits per pixel). Since Chrome 112, low-entropy images are ignored for LCP measurement. |
263 | | - |
264 | | -**Script:** `scripts/LCP-Image-Entropy.js` |
265 | | - |
266 | | -**Thresholds:** |
267 | | - |
268 | | -| BPP | Entropy | LCP Eligible | Example | |
269 | | -|-----|---------|--------------|---------| |
270 | | -| < 0.05 | 🔴 Low | ❌ No | Solid colors, simple gradients, placeholders | |
271 | | -| ≥ 0.05 | 🟢 Normal | ✅ Yes | Photos, complex graphics | |
272 | | - |
273 | | ---- |
274 | | - |
275 | | -## LCP Sub-Parts |
276 | | - |
277 | | -Breaks down Largest Contentful Paint into its four phases to identify optimization opportunities. Understanding which phase is slowest helps you focus your optimization efforts where they'll have the most impact. Based on the Web Vitals Chrome Extension. |
278 | | - |
279 | | -**Script:** `scripts/LCP-Sub-Parts.js` |
280 | | - |
281 | | ---- |
282 | | - |
283 | | -## LCP Trail |
284 | | - |
285 | | -Tracks every LCP candidate element during page load and highlights each one with a distinct pastel-colored dashed outline — so you can see the full trail from first candidate to final LCP. |
286 | | - |
287 | | -**Script:** `scripts/LCP-Trail.js` |
288 | | - |
289 | | ---- |
290 | | - |
291 | | -## LCP Video Candidate |
292 | | - |
293 | | -Detects whether the LCP element is a <video> and audits the poster image configuration — the most common source of avoidable LCP delay when video is the hero element. |
294 | | - |
295 | | -**Script:** `scripts/LCP-Video-Candidate.js` |
296 | | - |
297 | | ---- |
298 | | - |
299 | | -## Largest Contentful Paint (LCP) |
300 | | - |
301 | | -Quick check for Largest Contentful Paint, a Core Web Vital that measures loading performance. LCP marks when the largest content element becomes visible in the viewport. |
302 | | - |
303 | | -**Script:** `scripts/LCP.js` |
| 222 | +## References |
304 | 223 |
|
305 | | -**Thresholds:** |
| 224 | +- `references/snippets.md` — Descriptions and thresholds for each script |
| 225 | +- `references/schema.md` — Return value schema for interpreting script output |
306 | 226 |
|
307 | | -| Rating | Time | Meaning | |
308 | | -|--------|------|---------| |
309 | | -| 🟢 Good | ≤ 2.5s | Fast, content appears quickly | |
310 | | -| 🟡 Needs Improvement | ≤ 4s | Moderate delay | |
311 | | -| 🔴 Poor | > 4s | Slow, users may abandon | |
| 227 | +> Execute via `mcp__chrome-devtools__evaluate_script` → read with `mcp__chrome-devtools__get_console_message`. |
0 commit comments