WebPerf: Interaction & Animation
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.
Scripts
- -
scripts/Input-Latency-Breakdown.js — Input Latency Breakdown - INLINECODE3 — Interactions
- INLINECODE4 — Layout Shift Tracking
- INLINECODE5 — LoAF Helpers
- INLINECODE6 — Long Animation Frames Script Attribution
- INLINECODE7 — Long Animation Frames (LoAF)
- INLINECODE8 — Long Tasks
- INLINECODE9 — Scroll Performance Analysis
Descriptions and thresholds: INLINECODE10
Common Workflows
Complete Interaction Performance Audit
When the user asks for interaction analysis or "audit responsiveness":
- 1. Interactions.js - List all user interactions with timing
- Input-Latency-Breakdown.js - Break down interaction phases
- Long-Animation-Frames.js - Detect blocking animation frames
- LongTask.js - Identify long tasks blocking the main thread
- Scroll-Performance.js - Measure scroll smoothness
INP Deep Dive
When INP is slow (>200ms) or the user asks "debug INP" or "slow interactions":
- 1. Interactions.js - Identify which interactions are slow
- Input-Latency-Breakdown.js - Break down into input delay, processing time, presentation delay
- Long-Animation-Frames.js - Find animation frames >50ms that block interactions
- Long-Animation-Frames-Script-Attribution.js - Identify scripts causing the blocking
- Long-Animation-Frames-Helpers.js - Get detailed timing and attribution helpers
Scroll Jank Investigation
When the user reports "scroll jank", "choppy scrolling", or "scroll performance issues":
- 1. Scroll-Performance.js - Measure scroll smoothness and frame drops
- Long-Animation-Frames.js - Detect frames causing jank (>50ms)
- Layout-Shift-Loading-and-Interaction.js - Check for layout shifts during scroll
- Long-Animation-Frames-Script-Attribution.js - Find scripts running during scroll
Main Thread Blocking Analysis
When the page feels unresponsive or the user asks "why is the page frozen":
- 1. LongTask.js - List all tasks >50ms blocking the main thread
- Long-Animation-Frames.js - Correlate with animation frame timing
- Long-Animation-Frames-Script-Attribution.js - Attribute blocking to specific scripts
- Cross-reference with webperf-loading skill:
- JS-Execution-Time-Breakdown.js (script parsing/execution time)
- First-And-Third-Party-Script-Info.js (identify third-party blockers)
Layout Shift During Interaction
When the user reports "things move when I click" or CLS issues during interaction:
- 1. Layout-Shift-Loading-and-Interaction.js - Separate loading vs interaction shifts
- Interactions.js - Correlate shifts with specific interactions
- CLS.js (from Core Web Vitals skill) - Measure total CLS
- Cross-reference with webperf-media skill:
- Image-Element-Audit.js (images without dimensions causing shifts)
Animation Performance Analysis
When animations feel sluggish or the user asks "debug animation performance":
- 1. Long-Animation-Frames.js - Identify frames taking too long to render
- Long-Animation-Frames-Helpers.js - Detailed frame timing analysis
- Long-Animation-Frames-Script-Attribution.js - Find scripts delaying frames
- Scroll-Performance.js - If scroll animations are involved
Third-Party Script Impact on Interactions
When interactions are slow and third-party scripts are suspected:
- 1. Long-Animation-Frames-Script-Attribution.js - Identify third-party scripts in long frames
- LongTask.js - Measure long task frequency
- Cross-reference with webperf-loading skill:
- First-And-Third-Party-Script-Info.js (list all third-party scripts)
- First-And-Third-Party-Script-Timings.js (measure script loading impact)
- Script-Loading.js (check for blocking scripts)
Decision Tree
Use this decision tree to automatically run follow-up snippets based on results:
After Interactions.js
- - If any interaction > 200ms → Run Input-Latency-Breakdown.js on slow interactions
- If many interactions > 200ms → Main thread congestion, run:
1.
Long-Animation-Frames.js (blocking frames)
2.
LongTask.js (long tasks)
3.
Long-Animation-Frames-Script-Attribution.js (culprit scripts)
- - If specific interaction types are slow (e.g., click vs keyboard) → Focus on that interaction type
- If interactions occur during page load → Cross-check with webperf-loading:JS-Execution-Time-Breakdown.js
After Input-Latency-Breakdown.js
- - If Input Delay > 50ms → Main thread was busy, run:
1.
Long-Animation-Frames.js (what was blocking)
2.
LongTask.js (long task before interaction)
- - If Processing Time > 100ms → Heavy event handlers, run:
1.
Long-Animation-Frames-Script-Attribution.js (which scripts)
2.
webperf-loading:First-And-Third-Party-Script-Info.js (third-party involvement)
- - If Presentation Delay > 50ms → Rendering bottleneck, run:
1.
Long-Animation-Frames.js (frame rendering time)
2.
Layout-Shift-Loading-and-Interaction.js (check for layout work)
After Long-Animation-Frames.js
- - If many frames > 50ms → Run Long-Animation-Frames-Script-Attribution.js to identify causes
- If frames > 100ms → Critical blocking, run:
1.
Long-Animation-Frames-Script-Attribution.js (detailed attribution)
2.
LongTask.js (related long tasks)
3.
webperf-loading:JS-Execution-Time-Breakdown.js (script execution cost)
- - If frames occur during scroll → Run Scroll-Performance.js to measure impact
- If frames occur during page load → Cross-check with webperf-loading:Event-Processing-Time.js
After Long-Animation-Frames-Script-Attribution.js
- - If third-party scripts are causing long frames → Run:
1.
webperf-loading:First-And-Third-Party-Script-Info.js (list all third-party scripts)
2.
webperf-loading:Script-Loading.js (check loading strategy)
3. Recommend deferring or removing problematic scripts
- - If first-party scripts are causing long frames → Recommend:
- Code splitting
- Debouncing/throttling event handlers
- Web Workers for heavy computation
- - If forced reflow/layout detected → Analyze DOM manipulation patterns
After LongTask.js
- - If many long tasks (>5) → Main thread is congested, run:
1.
Long-Animation-Frames-Script-Attribution.js (detailed attribution)
2.
webperf-loading:JS-Execution-Time-Breakdown.js (script execution analysis)
3.
webperf-loading:First-And-Third-Party-Script-Info.js (identify heavy scripts)
- - If long tasks > 500ms → Critical blocking, investigate:
- Synchronous third-party scripts
- Heavy computation without Web Workers
- Excessive DOM manipulation
- - If long tasks correlate with interactions → Run Interactions.js to see impact
After Scroll-Performance.js
- - If scroll FPS < 30 → Severe jank, run:
1.
Long-Animation-Frames.js (blocking frames during scroll)
2.
Long-Animation-Frames-Script-Attribution.js (scripts running on scroll)
3.
Layout-Shift-Loading-and-Interaction.js (layout work during scroll)
- - If scroll FPS 30-50 → Noticeable jank, investigate:
- Scroll event handlers
- Passive event listeners
- CSS will-change properties
- - If scroll FPS > 50 → Good, but check for layout shifts during scroll
After Layout-Shift-Loading-and-Interaction.js
- - If shifts occur during page load → Cross-reference with webperf-core-web-vitals:CLS.js
- If shifts occur during interaction → This impacts INP and UX, investigate:
1. Dynamic content insertion
2. Images/ads loading without dimensions
3. Font swaps (run
webperf-loading:Fonts-Preloaded-Loaded-and-used-above-the-fold.js)
- - If shifts occur during scroll → Run Scroll-Performance.js to measure impact
After Long-Animation-Frames-Helpers.js
This is a utility snippet, use results to:
- - Understand frame timing in detail
- Identify precise script attribution
- Measure style/layout/paint phases
- No automatic follow-up, use data to inform next steps
Cross-Skill Triggers
These triggers recommend using snippets from other skills:
From Interaction to Core Web Vitals Skill
- - If INP > 200ms detected → Use webperf-core-web-vitals skill:
- INP.js (official INP measurement)
- LCP-Sub-Parts.js (if render delay is causing INP)
- - If layout shifts during interaction → Use webperf-core-web-vitals skill:
- CLS.js (measure cumulative impact)
- LCP-Trail.js (check if shifts affect LCP candidate)
From Interaction to Loading Skill
- - If long frames caused by script execution → Use webperf-loading skill:
- JS-Execution-Time-Breakdown.js (parsing vs execution time)
- First-And-Third-Party-Script-Info.js (identify heavy scripts)
- Script-Loading.js (check for blocking patterns)
- - If interactions slow during page load → Use webperf-loading skill:
- Event-Processing-Time.js (page load phases)
- Find-render-blocking-resources.js (competing resources)
From Interaction to Media Skill
- - If layout shifts involve images → Use webperf-media skill:
- Image-Element-Audit.js (check for missing dimensions)
Performance Budget Thresholds
Use these thresholds to automatically trigger follow-up analysis:
INP Thresholds:
- - Good: ≤ 200ms → Monitor, no action needed
- Needs Improvement: 200-500ms → Run Input-Latency-Breakdown.js
- Poor: > 500ms → Run full INP debugging workflow (5 snippets)
Long Animation Frames:
- - Warning: > 50ms → Run Long-Animation-Frames-Script-Attribution.js
- Critical: > 100ms → Run full main thread blocking workflow
Long Tasks:
- - Warning: > 50ms → Monitor frequency
- Critical: > 200ms or >5 tasks per second → Run attribution and script analysis
Scroll Performance:
- - Good: ≥ 50 FPS → Monitor
- Needs Improvement: 30-50 FPS → Run Long-Animation-Frames.js
- Poor: < 30 FPS → Run full scroll jank workflow
Interaction Frequency:
- - If >10 interactions/second → User is actively interacting, prioritize INP optimization
- If <1 interaction/5 seconds → Interactions are rare, focus on first interaction responsiveness
Multi-Metric Correlation
When multiple interaction metrics are poor:
- - If Long Tasks AND Long Animation Frames both detected → Shared root cause:
1. Run Long-Animation-Frames-Script-Attribution.js
2. Likely heavy JavaScript execution
3. Consider code splitting or Web Workers
- - If INP slow AND CLS high → Interaction-triggered layout shifts:
1. Run Layout-Shift-Loading-and-Interaction.js
2. Correlate shift timing with interaction timing
3. Check for dynamic content insertion
- - If Scroll jank AND Long Animation Frames → Scroll handlers blocking main thread:
1. Run Long-Animation-Frames-Script-Attribution.js during scroll
2. Check for non-passive scroll listeners
3. Audit scroll-triggered animations
References
- -
references/snippets.md — Descriptions and thresholds for each script - INLINECODE12 — Return value schema for interpreting script output
Execute via mcp__chrome-devtools__evaluate_script → read with mcp__chrome-devtools__get_console_message.
WebPerf: 交互与动画
用于在Chrome DevTools中测量Web性能的JavaScript代码片段。通过mcpchrome-devtoolsevaluatescript执行,使用mcpchrome-devtoolsgetconsole_message捕获输出。
脚本
- - scripts/Input-Latency-Breakdown.js — 输入延迟分解
- scripts/Interactions.js — 交互
- scripts/Layout-Shift-Loading-and-Interaction.js — 布局偏移追踪
- scripts/Long-Animation-Frames-Helpers.js — LoAF辅助工具
- scripts/Long-Animation-Frames-Script-Attribution.js — 长动画帧脚本归因
- scripts/Long-Animation-Frames.js — 长动画帧(LoAF)
- scripts/LongTask.js — 长任务
- scripts/Scroll-Performance.js — 滚动性能分析
描述和阈值:references/snippets.md
常见工作流程
完整交互性能审计
当用户请求交互分析或审计响应能力时:
- 1. Interactions.js - 列出所有用户交互及其时间
- Input-Latency-Breakdown.js - 分解交互阶段
- Long-Animation-Frames.js - 检测阻塞动画帧
- LongTask.js - 识别阻塞主线程的长任务
- Scroll-Performance.js - 测量滚动流畅度
INP深度分析
当INP较慢(>200ms)或用户要求调试INP或交互缓慢时:
- 1. Interactions.js - 识别哪些交互较慢
- Input-Latency-Breakdown.js - 分解为输入延迟、处理时间、呈现延迟
- Long-Animation-Frames.js - 查找阻塞交互的>50ms动画帧
- Long-Animation-Frames-Script-Attribution.js - 识别导致阻塞的脚本
- Long-Animation-Frames-Helpers.js - 获取详细时间和归因辅助
滚动卡顿调查
当用户报告滚动卡顿、滚动不流畅或滚动性能问题时:
- 1. Scroll-Performance.js - 测量滚动流畅度和丢帧情况
- Long-Animation-Frames.js - 检测导致卡顿的帧(>50ms)
- Layout-Shift-Loading-and-Interaction.js - 检查滚动期间的布局偏移
- Long-Animation-Frames-Script-Attribution.js - 查找滚动期间运行的脚本
主线程阻塞分析
当页面感觉无响应或用户询问页面为何冻结时:
- 1. LongTask.js - 列出所有阻塞主线程的>50ms任务
- Long-Animation-Frames.js - 与动画帧时间关联
- Long-Animation-Frames-Script-Attribution.js - 将阻塞归因于特定脚本
- 与webperf-loading技能交叉引用:
- JS-Execution-Time-Breakdown.js (脚本解析/执行时间)
- First-And-Third-Party-Script-Info.js (识别第三方阻塞器)
交互期间的布局偏移
当用户报告点击时内容移动或交互期间出现CLS问题时:
- 1. Layout-Shift-Loading-and-Interaction.js - 区分加载与交互偏移
- Interactions.js - 将偏移与特定交互关联
- CLS.js (来自Core Web Vitals技能) - 测量总CLS
- 与webperf-media技能交叉引用:
- Image-Element-Audit.js (缺少尺寸导致偏移的图片)
动画性能分析
当动画感觉卡顿或用户要求调试动画性能时:
- 1. Long-Animation-Frames.js - 识别渲染时间过长的帧
- Long-Animation-Frames-Helpers.js - 详细帧时间分析
- Long-Animation-Frames-Script-Attribution.js - 查找延迟帧的脚本
- Scroll-Performance.js - 如果涉及滚动动画
第三方脚本对交互的影响
当交互缓慢且怀疑第三方脚本时:
- 1. Long-Animation-Frames-Script-Attribution.js - 识别长帧中的第三方脚本
- LongTask.js - 测量长任务频率
- 与webperf-loading技能交叉引用:
- First-And-Third-Party-Script-Info.js (列出所有第三方脚本)
- First-And-Third-Party-Script-Timings.js (测量脚本加载影响)
- Script-Loading.js (检查阻塞脚本)
决策树
使用此决策树根据结果自动运行后续代码片段:
执行Interactions.js后
- - 如果有任何交互 > 200ms → 对慢交互运行Input-Latency-Breakdown.js
- 如果多个交互 > 200ms → 主线程拥塞,运行:
1.
Long-Animation-Frames.js (阻塞帧)
2.
LongTask.js (长任务)
3.
Long-Animation-Frames-Script-Attribution.js (问题脚本)
- - 如果特定交互类型较慢(如点击 vs 键盘) → 专注于该交互类型
- 如果交互发生在页面加载期间 → 与webperf-loading:JS-Execution-Time-Breakdown.js交叉检查
执行Input-Latency-Breakdown.js后
- - 如果输入延迟 > 50ms → 主线程繁忙,运行:
1.
Long-Animation-Frames.js (什么在阻塞)
2.
LongTask.js (交互前的长任务)
- - 如果处理时间 > 100ms → 事件处理程序过重,运行:
1.
Long-Animation-Frames-Script-Attribution.js (哪些脚本)
2.
webperf-loading:First-And-Third-Party-Script-Info.js (第三方参与)
- - 如果呈现延迟 > 50ms → 渲染瓶颈,运行:
1.
Long-Animation-Frames.js (帧渲染时间)
2.
Layout-Shift-Loading-and-Interaction.js (检查布局工作)
执行Long-Animation-Frames.js后
- - 如果多个帧 > 50ms → 运行Long-Animation-Frames-Script-Attribution.js识别原因
- 如果帧 > 100ms → 严重阻塞,运行:
1.
Long-Animation-Frames-Script-Attribution.js (详细归因)
2.
LongTask.js (相关长任务)
3.
webperf-loading:JS-Execution-Time-Breakdown.js (脚本执行成本)
- - 如果帧发生在滚动期间 → 运行Scroll-Performance.js测量影响
- 如果帧发生在页面加载期间 → 与webperf-loading:Event-Processing-Time.js交叉检查
执行Long-Animation-Frames-Script-Attribution.js后
1.
webperf-loading:First-And-Third-Party-Script-Info.js (列出所有第三方脚本)
2.
webperf-loading:Script-Loading.js (检查加载策略)
3. 建议延迟或移除有问题的脚本
- 代码分割
- 防抖/节流事件处理程序
- 使用Web Workers处理繁重计算
- - 如果检测到强制回流/布局 → 分析DOM操作模式
执行LongTask.js后
- - 如果多个长任务(>5) → 主线程拥塞,运行:
1.
Long-Animation-Frames-Script-Attribution.js (详细归因)
2.
webperf-loading:JS-Execution-Time-Breakdown.js (脚本执行分析)
3.
webperf-loading:First-And-Third-Party-Script-Info.js (识别重脚本)
- - 如果长任务 > 500ms → 严重阻塞,调查:
- 同步第三方脚本
- 未使用Web Workers的繁重计算
- 过度DOM操作
- - 如果长任务与交互相关 → 运行Interactions.js查看影响
执行Scroll-Performance.js后
- - 如果滚动FPS < 30 → 严重卡顿,运行:
1.
Long-Animation-Frames.js (滚动期间阻塞帧)
2.
Long-Animation-Frames-Script-Attribution.js (滚动时运行的脚本)
3.
Layout-Shift-Loading-and-Interaction.js (滚动期间的布局工作)
- - 如果滚动FPS 30-50 → 明显卡顿,调查:
- 滚动事件处理程序
-