responsive-size
它能做什么
这个技能比较每张图片的实际尺寸与它在屏幕上的显示尺寸,并修复过大的图片。它面向因为图片过大而导致页面加载缓慢的网站构建者。
适用场景
- ✓你请智能体找出网站上过大的图片的时候。
- ✓页面审计报告显示图片比实际需要的尺寸大的时候。
- ✓首图非常大,但在手机上显示在很小的容器中的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/responsive-size/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我网站上的一些照片与它们在屏幕上的显示大小相比非常大。请帮我找出它们并制作较小的版本吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在常见屏幕尺寸下,比较每张图片的真实宽度与其显示宽度。对于过大的图片,它会制作多种宽度的版本,并添加 srcset 和 sizes,让浏览器选择合适的版本。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
srcsetwith width descriptors andsizeswith actual layout widths - The
sizesattribute is critical—without it the browser assumes100vwand 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
常见问题
常见的尺寸组合是什么?
这个技能建议制作宽度为 400、800、1200 和 1600 像素的版本。
sizes 属性为什么重要?
这个技能说,没有它,浏览器会假定图片占满整个屏幕宽度,并选择最大的文件。
可以使用哪些工具调整图片大小?
这个技能提到可以用 Sharp 或 Squoosh 来制作这些版本。
详情
作者的原始描述
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.
热度
- GitHub 星标
- 75k
- 排名
- #2998
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。