本文へスキップ
Skillpedia
画像とアイコン75k · #3034

srcset

できること

このスキルは、サイトの画像タグを確認し、srcsetとsizesの属性が不足している箇所に追加し、レイアウトに合わないものを直します。どの端末でも効率よく画像が読み込まれることを求める制作者向けです。

使う場面

  • ✓サイトの画像が、各端末に合ったサイズで読み込まれるようにするようエージェントに頼むとき。
  • ✓スマートフォンがデスクトップ向けの大きな画像をダウンロードし、モバイル通信の訪問者から遅いと言われるとき。
  • ✓画像にsrcsetはあるのに、そのsizes属性が表示のレイアウトと合っていないとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/srcset/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/srcset/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

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 srcset with width descriptors (400w, 800w) to all images wider than ~100px
  • Always pair srcset width descriptors with a sizes attribute—without sizes the browser assumes 100vw
  • Use density descriptors (1x, 2x) only for fixed-size images like avatars and icons
  • Keep src pointing to a fallback size for browsers that don't support srcset

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.

Rule page: https://frontendchecklist.io/rules/images/srcset

よくある質問

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.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#3034
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル