dimensions
Fungsinya
Skill ini memeriksa tag gambar di situs web untuk pengaturan ukuran yang hilang. Cocok untuk pengembang yang menginginkan halaman yang tetap stabil saat dimuat.
Kapan dipakai
- āSaat konten di halaman Anda melompat ketika foto selesai dimuat.
- āSaat Anda menambahkan gambar baru ke halaman atau templat.
- āSaat halaman Anda mendapat skor buruk pada pemeriksaan stabilitas tata letak.
Link skill
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/dimensions/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
āBisakah Anda menemukan gambar di situs saya yang tidak memiliki lebar dan tinggi?ā
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memindai tag gambar dan melaporkan yang tidak memiliki lebar atau tinggi. Agent menyarankan penambahan ukuran asli gambar agar browser menyediakan ruang sebelum gambar dimuat.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
widthandheightattributes on<img>matching the image's intrinsic dimensions - Pair with
height: autoin 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-ratiofrom 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
Pertanyaan umum
Mengapa gambar tanpa ukuran menimbulkan masalah?
Browser tidak tahu seberapa besar ruang yang harus disisakan, sehingga teks di bawahnya bergeser ketika gambar muncul.
Apakah ikon dekoratif kecil juga termasuk?
Skill memperlakukan gambar dekoratif kecil sebagai prioritas rendah, karena jarang menggeser konten di sekitarnya.
Skor berapa yang dianggap baik?
Skill menyatakan skor pergeseran tata letak di bawah 0,1 dianggap baik, dan di atas 0,25 dianggap buruk.
Detail
Deskripsi asli dari pembuat
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.
Popularitas
- Bintang GitHub
- 75k
- Peringkat
- #2815
- Lisensi
- MIT
- Diperbarui
- 31/10/2026
Komentar
- ā¦
Skill lain dari repositori ini
frontendchecklist
75kMemeriksa kode frontend dan halaman langsung terhadap lebih dari 380 aturan untuk aksesibilitas, kecepatan, SEO, dan keamanan, dengan alat baris perintah.
frontend-checklist-global
75kMengaudit proyek frontend terhadap seluruh 386 aturan Front-End Checklist, dan memberikan perbaikan spesifik untuk setiap masalah yang ditemukan.
404-page
75kMemeriksa bahwa halaman tidak ditemukan Anda menawarkan tautan yang membantu dan mengembalikan status 404 yang sebenarnya, untuk membantu pengunjung yang tersesat.
about-page
75kMeninjau apakah situs Anda memiliki halaman Tentang yang jelas yang menjelaskan siapa yang mengelolanya, untuk membangun kepercayaan pengunjung dan mesin pencari.
Skill serupa
angular-developer
280kMembantu agent Anda membuat kode Angular dan memberi saran struktur proyek. Berguna saat memulai proyek baru, membuat komponen, atau meningkatkan performa.
frontend-a11y
280kMembantu agent Anda membuat antarmuka web dapat diakses semua orang. Memastikan website dan aplikasi berfungsi baik dengan screen reader dan navigasi keyboard.
frontend-patterns
280kMembuat agent Anda menerapkan pola modern dalam frontend. Mengoptimalkan performa, mengelola state, dan mengikuti praktik terbaik React dan Next.js.