用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill responsive-images命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | responsive-images |
| description | Image formats, srcset, picture element, lazy loading |
| triggers | {"extensions":[".tsx",".html"],"keywords":["Image","srcset","picture","next/image","WebP","AVIF","lazy load","optimization"]} |
| auto_load_when | Optimizing or implementing images |
| agent | style-architect |
| tools | ["Read","Write","Bash"] |
Focus: Formats, srcset, picture element, lazy loading
When to use WebP:
├── Browser support → 96%+ support
├── Transparency → yes
├── Animation → yes
├── Size reduction → 25-35% smaller
└── Fallback → JPEG/PNG
When to use AVIF:
├── Chrome/Firefox → yes
├── Highest compression → yes
├── HDR support → yes
├── Fallback → WebP/JPEG
When to use SVG:
├── Icons/logos → yes
├── Simple graphics → yes
├── Responsive → yes
├── Animation → yes
When to use JPEG:
├── Photos → yes
├── Compatibility → best
└── No transparency → yes
When to use srcset:
├── Responsive → yes
├── Multiple widths → yes
├── Bandwidth variation → yes
└── Browser selection → yes
When to use sizes:
├── Same crop → srcset + sizes
├── Different crop → picture element
├── Viewport-based → media queries
└── Single image → no srcset needed
Sizes guidelines:
├── Full width → 100vw
├── Half width → 50vw
├── Third width → 33vw
└── Specific breakpoint → media query
When to use picture:
├── Art direction → yes (different crops)
├── Format switching → yes (AVIF/WebP/JPEG)
├── Dpr switching → yes (1x/2x/3x)
└── Viewport-based art → yes
Format switching pattern:
├── <picture> + <source type="image/avif">
├── <source type="image/webp">
└── <img> fallback (JPEG or PNG)
When multiple sources:
├── Type + media → both in source
├── Order matters → most capable first
└──.img fallback → last
When to use loading=lazy:
├── Below fold → yes
├── Not in viewport → yes
├── Not immediate → yes
└── Large number → yes
When to eager load:
├── Above fold → yes (eager or default)
├── First 1-2 images → yes
├── LCP element → yes
└── User scrolls immediately → yes
When to use IntersectionObserver:
├── Custom threshold → yes
├── Progressive loading → yes
├── Animation trigger → yes
└── Native lazy not supported → no (legacy)
When to preload:
├── LCP image → yes
├── Critical → yes
├── Above fold → above fold
└── Not critical → no preload
Preload syntax:
<link rel="preload" as="image" href="large.jpg">
<link rel="preload" as="image" href="large.avif" type="image/avif">
When to decode:
├── Large image → async
├── Blocking render → sync (avoid)
└── Progressive → async
When to use decoding attribute:
├── Above fold → sync (if LCP)
├── Below fold → async
└── Largest content → sync
When image is biggest resource:
├── Optimize format → AVIF/WebP
├── Right size → srcset + sizes
├── Compression → lossy acceptable
└── CDN → use
When to use src:
├── Single size → src only
├── Static size → src only
├── Responsive → srcset or picture
└── Different crop → picture
When to check metrics:
├── Lighthouse → yes
├── Field data → yes
├── RUM → if possible
└── All formats → test each
❌ Single 2000px image served to all devices
✅ srcset with multiple widths: 400w, 800w, 1200w
❌ Loading all images on page load (even below fold)
✅ loading="lazy" on all below-fold images
❌ JPEG for everything
✅ AVIF → WebP → JPEG with <picture> format fallbacks
❌ No width/height on images (causes layout shift)
✅ Always set width and height to prevent CLS
❌ CSS background-image for hero images (not optimizable)
✅ <img> with LCP optimization; CSS bg only for decorative
| Scenario | Solution | Attribute |
|---|---|---|
| Responsive sizes | srcset + sizes | sizes="(max-width:768px) 100vw, 50vw" |
| Lazy load | Native lazy | loading="lazy" |
| Format fallback | type="image/avif" | |
| LCP image | Eager + preload | loading="eager" fetchpriority="high" |
| Prevent CLS | Explicit dimensions | width="800" height="600" |
| Art direction | Different crops per breakpoint |