Chuyển đến nội dung
Skillpedia
Hình ảnh và biểu tượng75k · #2998

responsive-size

Skill này làm gì

Skill này so sánh kích thước thật của mỗi ảnh với kích thước hiển thị trên màn hình và sửa các ảnh quá lớn. Skill dành cho người xây web có trang tải chậm vì ảnh quá khổ.

Khi nào nên dùng

  • ✓Khi bạn yêu cầu agent tìm các ảnh quá lớn trên website.
  • ✓Khi kết quả kiểm tra trang báo ảnh lớn hơn mức cần thiết.
  • ✓Khi ảnh tiêu đề rất lớn nhưng hiển thị trong một khung nhỏ trên điện thoại.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/responsive-size/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Một số ảnh trên website của tôi rất lớn so với cách chúng hiển thị trên màn hình. Bạn có thể tìm chúng và tạo phiên bản nhỏ hơn không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent so sánh chiều rộng thật của mỗi ảnh với chiều rộng hiển thị ở các kích thước màn hình phổ biến. Với ảnh quá lớn, agent tạo các biến thể ở nhiều chiều rộng và thêm srcset cùng sizes để trình duyệt chọn đúng phiên bản.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Serve images at the correct display size

A single oversized hero image can add several megabytes to a page load unnecessarily. On mobile devices with 375px screens, serving a 1600px image downloads 4x the data users need. The 'Properly size images' Lighthouse audit consistently identifies this as one of the highest-impact performance opportunities on most websites.

Quick Reference

  • Serving a 1600px image in a 400px container wastes ~16x the necessary bandwidth
  • Use srcset with width descriptors and sizes with actual layout widths
  • The sizes attribute is critical—without it the browser assumes 100vw and picks the largest image
  • Lighthouse 'Properly size images' audit reports estimated savings per oversized image

Check

Audit images in this codebase for oversizing. Use Lighthouse 'Properly size images' audit results as the primary signal. For each <img> in the HTML: 1) Compare the image file's intrinsic width to the element's rendered CSS width (check CSS rules, container constraints). 2) Flag any image where the intrinsic width is more than 2x the rendered width at any common viewport size. 3) Check for srcset usage—images over 200px wide should have srcset variants. 4) Check sizes attribute accuracy—does it reflect the actual CSS layout?

Fix

For each oversized image: 1) Generate multiple size variants: 400w, 800w, 1200w, 1600w (use Sharp or Squoosh). 2) Add srcset listing each variant with its width descriptor. 3) Add a sizes attribute describing the image's display width at each breakpoint (e.g., sizes="(max-width: 600px) 100vw, (max-width: 1200px) 50vw, 400px"). 4) For art direction (different crops), use <picture> with media attributes. 5) For the <img> src fallback, use the medium size (800w). Show complete before/after HTML.

Explain

Explain why serving oversized images wastes bandwidth. If a browser renders an image at 400px wide but the image file is 2000px wide, the browser downloads ~25x more pixel data than it can display (bandwidth scales with pixel count, not linear dimensions). The Lighthouse 'Properly size images' audit estimates potential savings in KiB for each oversized image. The sizes attribute is the key to accuracy—without it, the browser assumes 100vw and downloads the largest srcset candidate even on narrow viewports.

Code Review

Review image assets, markup, and delivery configuration related to Serve images at the correct display size. 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/responsive-size

Câu hỏi thường gặp

Một bộ kích thước điển hình là gì?

Skill gợi ý các biến thể rộng 400, 800, 1200 và 1600 điểm ảnh.

Vì sao thuộc tính sizes quan trọng?

Skill nói nếu thiếu nó, trình duyệt cho rằng ảnh trải đủ chiều rộng màn hình và chọn tệp lớn nhất.

Công cụ nào có thể đổi kích thước ảnh?

Skill nhắc đến Sharp hoặc Squoosh để tạo các biến thể.

Chi tiết

Mô tả gốc của tác giả

Use when reviewing image assets, markup, and CDN or build transforms related to Serve images at the correct display size. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2998
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự