本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #2815

dimensions

できること

このスキルは、Webサイトの画像のタグに、サイズの設定がないものがないかを確認します。読み込み中も安定しているページを作りたい開発者向けです。

使う場面

  • ✓写真の読み込みが終わるにつれて、ページの内容が動くとき。
  • ✓ページやテンプレートに新しい画像を追加するとき。
  • ✓レイアウトの安定性のチェックで、ページのスコアが悪いとき。

スキルのリンク

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

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“私のサイトで、幅と高さがない画像を見つけてもらえますか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは画像のタグをスキャンし、幅または高さがないものを報告します。画像の実際のサイズを追加し、画像が読み込まれる前にブラウザが場所を確保できるようにすることを提案します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Set explicit width and height on images

Images without explicit dimensions are the most common cause of Cumulative Layout Shift (CLS), a Core Web Vitals metric. When images load and cause layout jumps, users accidentally click the wrong element—a frustrating experience that Google penalises in search rankings. A CLS score above 0.1 is considered 'needs improvement'; above 0.25 is 'poor'.

Quick Reference

  • Reserve findings for meaningful content images; decorative micro-SVGs or ornament-only assets are low-priority exceptions when CSS already reserves stable space
  • Example low-risk exception: <img src="/divider.svg" alt="" aria-hidden="true"> should not be flagged on its own without evidence of visible layout shift
  • Always set width and height attributes on <img> matching the image's intrinsic dimensions
  • Pair with height: auto in CSS to keep the image fluid while preserving the aspect ratio
  • Missing dimensions are the leading cause of Cumulative Layout Shift (CLS) from images
  • Browsers derive aspect-ratio from these attributes—do not set arbitrary placeholder values

Check

Scan all <img> elements in the codebase. Identify any that are missing either the width or height attribute. Also check <source> elements inside <picture>—dimensions should be on the <img> fallback. Report each image missing dimensions with its file path and line number. Note: SVG icons under 32px, tiny decorative SVG ornaments with stable CSS sizing, and images loaded as CSS backgrounds are exempt.

Fix

For each <img> missing width/height: 1) Add the intrinsic pixel dimensions as attributes (e.g., width="800" height="450"). 2) Use CSS max-width: 100% and height: auto on the element to keep it responsive. 3) The attribute values must match the image's intrinsic aspect ratio—do not set arbitrary numbers. 4) For dynamically sized images, calculate the aspect ratio and use the CSS aspect-ratio property as a fallback. 5) Skip purely decorative micro assets when the snippet already shows stable sizing and there is no evidence of layout shift risk. Show the before and after HTML for each fixed image.

Explain

Explain why width and height attributes on <img> prevent Cumulative Layout Shift (CLS). When a browser parses HTML, it does not yet know an image's dimensions—without explicit attributes, the browser initially renders a 0-height placeholder, then jumps the layout when the image loads. With width and height set, the browser calculates the aspect ratio from the attributes and reserves space immediately, eliminating the shift. This became especially important as modern browsers use the aspect-ratio CSS property derived from these HTML attributes.

Code Review

Review image assets, markup, and delivery configuration related to Set explicit width and height on 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/dimensions

よくある質問

サイズのない画像は、なぜ問題を起こしますか?

ブラウザはどれだけの場所を空けるべきかを知らないため、画像が表示されると下の文章が動いてしまうと、このスキルは説明しています。

小さな装飾アイコンも対象ですか?

小さな装飾画像は優先度を低く扱うと、このスキルは説明しています。周囲の内容を動かすことはほとんどないためです。

どのスコアが良いとされますか?

レイアウトのずれのスコアが0.1未満なら良好、0.25を超えると不良だと、このスキルは説明しています。

詳細

作者による元の説明

Use when reviewing image assets, markup, and CDN or build transforms related to Set explicit width and height on images. Check encoded size, rendered size, loading strategy, and above-the-fold impact together. Separate real CLS risks from tiny decorative SVGs or ornament-only assets that are unlikely to move surrounding content.

repo: thedaviddias/Front-End-Checklist

人気

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

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

0

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

コメント

  • …

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

似ているスキル