srcset
できること
このスキルは、サイトの画像タグを確認し、srcsetとsizesの属性が不足している箇所に追加し、レイアウトに合わないものを直します。どの端末でも効率よく画像が読み込まれることを求める制作者向けです。
使う場面
- ✓サイトの画像が、各端末に合ったサイズで読み込まれるようにするようエージェントに頼むとき。
- ✓スマートフォンがデスクトップ向けの大きな画像をダウンロードし、モバイル通信の訪問者から遅いと言われるとき。
- ✓画像にsrcsetはあるのに、そのsizes属性が表示のレイアウトと合っていないとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/srcset/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“スマートフォンが、デスクトップ向けの大きな画像をダウンロードしています。各端末に合うサイズが届くように、srcsetを追加してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、約100ピクセルより大きくsrcsetがない画像を見つけ、400、800、1200ピクセルなどの幅のバージョンを作ります。srcsetのリストと、実際のレイアウトに合ったsizes属性を追加し、元のsrcのフォールバックも残します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Use srcset for responsive images
Without srcset, every user—regardless of their device—downloads the same large image. A 1600px hero image served to a 375px mobile display downloads 4x the data needed. The srcset attribute lets browsers choose the optimal file automatically, reducing bandwidth by 50-80% for mobile users with no change to visual quality.
Quick Reference
- Add
srcsetwith width descriptors (400w,800w) to all images wider than ~100px - Always pair
srcsetwidth descriptors with asizesattribute—withoutsizesthe browser assumes100vw - Use density descriptors (
1x,2x) only for fixed-size images like avatars and icons - Keep
srcpointing to a fallback size for browsers that don't supportsrcset
Check
Scan all <img> elements in this codebase. Flag: 1) Any <img> wider than 100px (in CSS or layout) that lacks a srcset attribute. 2) Any <img> with srcset but missing a sizes attribute (necessary for width descriptors). 3) Any <img> using only density descriptors (1x, 2x) where width descriptors (400w, 800w) would be more appropriate. 4) Any srcset that provides only one size (no benefit over plain src). Report each finding with file path and line number.
Fix
For each <img> missing srcset: 1) Generate multiple width variants: typically 400w, 800w, 1200w (add 1600w for full-bleed images). 2) Add srcset listing each variant with its width descriptor. 3) Add a sizes attribute describing actual CSS layout width at each breakpoint. 4) Keep src pointing to a mid-range size (800w) as the fallback. 5) Add width and height attributes if missing. For each image, show the complete corrected HTML including srcset and sizes.
Explain
Explain how srcset and the two descriptor types work. Width descriptors (400w, 800w) describe the intrinsic width of each candidate; the browser combines this with the sizes attribute to calculate which candidate provides the best pixel density for the current viewport. Density descriptors (1x, 2x) are simpler but less flexible—use them only for fixed-size images like avatars and icons. The sizes attribute is critical: without it, the browser assumes 100vw and always downloads the largest candidate even on narrow screens.
Code Review
Review image assets, markup, and delivery configuration related to Use srcset for responsive images. Flag exact files or components where format choice, sizing, or loading behavior violates the rule, and describe how to confirm the fix in DevTools.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
よくある質問
sizesはなぜ重要ですか?
このスキルによると、これがないとブラウザーは画像がビューポートの全幅だと仮定し、大きすぎるファイルを選ぶことがあるからです。
密度の記述子はいつ使うべきですか?
このスキルは、アバターやアイコンなど、サイズが固定の画像にだけ1xと2xを使うよう勧めています。
ページの見た目は変わりますか?
いいえ。このスキルによると、画像の見た目を変えずに、ダウンロードのサイズを減らします。
詳細
作者による元の説明
Use when reviewing image assets, markup, and CDN or build transforms related to Use srcset for responsive images. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.
人気
- GitHubのスター
- 75k
- ランキング
- #3034
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。