Webperf Media
by @nucliweb
Intelligent media optimization with automated workflows for images, videos, and SVGs. Includes decision trees that detect LCP images (triggers format/lazy-lo...
clawhub install webperf-mediaπ About This Skill
name: webperf-media description: Intelligent media optimization with automated workflows for images, videos, and SVGs. Includes decision trees that detect LCP images (triggers format/lazy-loading/priority analysis), identify layout shift risks (missing dimensions), and flag lazy loading issues (above-fold lazy or below-fold eager). Features workflows for complete media audit, LCP image investigation, video performance (poster optimization), and SVG embedded bitmap detection. Cross-skill integration with Core Web Vitals (LCP/CLS impact) and Loading (priority hints, resource preloading). Provides performance budgets and format recommendations based on content type. Use when the user asks about image optimization, LCP is an image/video, layout shifts from media, or media loading strategy. Compatible with Chrome DevTools MCP. license: MIT metadata: author: Joan Leon | @nucliweb version: 1.0.0 mcp-server: chrome-devtools category: web-performance repository: https://github.com/nucliweb/webperf-snippets
WebPerf: Media Performance
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/Image-Element-Audit.js β Image Element Auditscripts/SVG-Embedded-Bitmap-Analysis.js β SVG Embedded Bitmap Analysisscripts/Video-Element-Audit.js β Video Element AuditDescriptions and thresholds: references/snippets.md
Common Workflows
Complete Media Audit
When the user asks for media optimization or "audit images and videos":
1. Image-Element-Audit.js - Analyze all images (format, lazy loading, sizing, fetchpriority) 2. Video-Element-Audit.js - Analyze all videos (poster, preload, formats, autoplay) 3. SVG-Embedded-Bitmap-Analysis.js - Detect inefficient bitmap images embedded in SVGs
Image Optimization Workflow
When the user asks "optimize images" or "check image performance":
1. Image-Element-Audit.js - Full image audit 2. Cross-reference with webperf-loading skill: - Find-Above-The-Fold-Lazy-Loaded-Images.js (incorrectly lazy-loaded images) - Find-non-Lazy-Loaded-Images-outside-of-the-viewport.js (missing lazy loading) - Find-Images-With-Lazy-and-Fetchpriority.js (contradictory attributes) - Priority-Hints-Audit.js (LCP image should have fetchpriority="high")
Video Performance Audit
When the user asks "optimize videos" or "check video performance":
1. Video-Element-Audit.js - Full video audit 2. Cross-reference with webperf-core-web-vitals skill: - LCP-Video-Candidate.js (check if video/poster is LCP) 3. Cross-reference with webperf-loading skill: - Priority-Hints-Audit.js (video poster priority) - Resource-Hints-Validation.js (video preload)
LCP Image Investigation
When LCP is an image and needs optimization:
1. Cross-reference with webperf-core-web-vitals skill: - LCP.js (measure LCP) - LCP-Image-Entropy.js (analyze image complexity) 2. Image-Element-Audit.js - Check format, dimensions, lazy loading 3. Cross-reference with webperf-loading skill: - Find-Above-The-Fold-Lazy-Loaded-Images.js (should NOT be lazy) - Priority-Hints-Audit.js (should have fetchpriority="high") - Resource-Hints-Validation.js (consider preload)
Layout Shift from Images
When CLS is caused by images without dimensions:
1. Image-Element-Audit.js - Check for missing width/height attributes 2. Cross-reference with webperf-core-web-vitals skill: - CLS.js (measure total CLS) 3. Cross-reference with webperf-interaction skill: - Layout-Shift-Loading-and-Interaction.js (when shifts occur)
SVG Optimization Audit
When the user asks about SVG performance or file sizes are large:
1. SVG-Embedded-Bitmap-Analysis.js - Detect raster images embedded in vector SVGs 2. Recommend SVGO optimization for SVGs without embedded bitmaps 3. Recommend extracting bitmaps to separate image files with proper formats
Decision Tree
Use this decision tree to automatically run follow-up snippets based on results:
After Image-Element-Audit.js
After Video-Element-Audit.js
After SVG-Embedded-Bitmap-Analysis.js
Cross-Skill Triggers
These triggers recommend using snippets from other skills:
#### From Media to Core Web Vitals Skill
#### From Media to Loading Skill
#### From Media to Interaction Skill
Performance Budget Thresholds
Use these thresholds to trigger recommendations:
Image File Sizes:
Image Formats:
Image Dimensions:
Video File Sizes:
Lazy Loading:
Priority Hints:
Common Issues and Resolutions
Issue: LCP is slow and LCP element is an image 1. Run Image-Element-Audit.js 2. Run webperf-core-web-vitals:LCP-Image-Entropy.js 3. Check: format, lazy loading, fetchpriority, preload 4. Fix in order: remove lazy, add fetchpriority="high", optimize format, add preload
Issue: CLS from images 1. Run Image-Element-Audit.js 2. Check for missing width/height 3. Add explicit dimensions or aspect-ratio CSS 4. Verify with webperf-core-web-vitals:CLS.js
Issue: Page loads too many images 1. Run Image-Element-Audit.js 2. Run webperf-loading:Find-non-Lazy-Loaded-Images-outside-of-the-viewport.js 3. Implement lazy loading on below-fold images 4. Consider pagination or infinite scroll
Issue: Images are the wrong format 1. Run Image-Element-Audit.js 2. Check format vs content type 3. Recommend WebP with JPEG/PNG fallback 4. Consider AVIF for even better compression
Issue: Video is LCP 1. Run Video-Element-Audit.js 2. Run webperf-core-web-vitals:LCP-Video-Candidate.js 3. Optimize poster image or consider static image alternative 4. Add fetchpriority="high" to poster if keeping video
Issue: SVG files are huge 1. Run SVG-Embedded-Bitmap-Analysis.js 2. Extract embedded bitmaps 3. Run SVGO on pure SVG 4. Re-measure file sizes
References
references/snippets.md β Descriptions and thresholds for each scriptreferences/schema.md β Return value schema for interpreting script output> Execute via mcp__chrome-devtools__evaluate_script β read with mcp__chrome-devtools__get_console_message.