Agent skill
youtube-embed
YouTube video facade pattern for performance. Lazy-load iframe on click, poster images, GA4 tracking, Schema.org markup.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/youtube-embed
SKILL.md
YouTube Embed Skill
Purpose
Embed YouTube videos without loading YouTube scripts until user clicks. Massive performance win.
Core Rules
- Facade pattern — Poster + play button, no iframe until click
- Local posters — Download and optimize thumbnails locally
- Privacy-enhanced — Use
youtube-nocookie.comonly - Track engagement — GA4
video_playevent on click - Schema.org — VideoObject markup for rich snippets
Flow
Click before: Poster image + Play button (no YouTube)
Click after: Replace with iframe + GA4 event + autoplay
Poster Images
- Download:
https://i.ytimg.com/vi/{VIDEO_ID}/maxresdefault.jpg - Fallback:
sddefault.jpgif maxres unavailable - Convert: Use Picture skill (avif, webp, jpg)
- Store:
src/assets/videos/{slug}.jpg
References
- Component — Full VideoFacade.astro code
- Schema — VideoObject markup
Forbidden
- ❌ YouTube iframe/script before click
- ❌
youtube.com(must useyoutube-nocookie.com) - ❌
fetchpriority="high"on video facades - ❌ YouTube logo as play button (trademark)
- ❌ Remote poster images (always local)
- ❌ Missing poster or title
Definition of Done
- VideoFacade component created
- Poster images downloaded and optimized
- Click triggers iframe swap + autoplay
- GA4 video_play event firing
- VideoObject schema on pages with videos
- Keyboard accessible (Enter/Space)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?