image-file-size
它能做什么
这项技能审计项目中的图片文件,并报告任何对网页而言过大的文件。适用于希望页面快速、轻量的开发者和网站所有者。
适用场景
- ✓当你网站上的一张照片有好几兆大小的时候。
- ✓当你的首图拖慢了页面的首次显示的时候。
- ✓当你发布新图片,并希望先检查其大小的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/image-file-size/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我图片的文件大小,并告诉我哪些太大了。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会列出每张图片及其大小,并标记超过建议上限的图片,例如照片的 200 KB。它会建议转换为 WebP 或 AVIF,或为每种设备提供更小的尺寸。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Keep image file sizes within recommended limits
Images account for over 50% of average page weight according to HTTP Archive data. Oversized images waste user bandwidth (costly on mobile data plans), delay Largest Contentful Paint (LCP), and increase bounce rates. A 1-second delay in mobile page load can reduce conversions by up to 20% according to Google research.
Quick Reference
- Photos: target under 200KB (WebP 80% quality); under 400KB for full-bleed hero images
- Graphics/icons: target under 50KB; use SVG for vector graphics
- WebP is typically 25-35% smaller than equivalent-quality JPEG (per web.dev)
- AVIF is typically 40-50% smaller than equivalent-quality JPEG (per web.dev)
Check
Audit all image assets in this project. For each image: 1) Check the file size in bytes. 2) Flag any photo (JPEG/WebP/AVIF) over 200KB. 3) Flag any graphic/icon (PNG/SVG) over 100KB. 4) Flag any hero or full-width image over 400KB. 5) Flag any thumbnail (under 200px wide) over 30KB. Also check if Lighthouse reports 'Properly size images' or 'Efficiently encode images' as opportunities. Report each oversized image with its path, current size, and an estimated target size.
Fix
For each oversized image: 1) Convert JPEG/PNG to WebP at 80% quality using Squoosh, Sharp, or ImageOptim—this typically yields 25-35% size reduction over optimised JPEG. 2) Try AVIF at 60% quality for further reduction (often 40-50% smaller than JPEG). 3) Strip metadata (EXIF/IPTC) from images served on the web. 4) For PNGs, run through oxipng or pngquant for lossless or near-lossless compression. 5) For SVGs, run through SVGO. 6) Implement multiple srcset sizes so mobile users download smaller files.
Explain
Explain how oversized images impact web performance. Images are typically the largest assets on a page—HTTP Archive data consistently shows images account for 40-60% of total page weight. Each KB saved reduces transfer time, especially on mobile networks (4G averages 20Mbps, with significant latency). Large images also delay Largest Contentful Paint (LCP), the primary Core Web Vitals metric. Google's Lighthouse flags images that could be reduced by more than 4KB as an opportunity.
Code Review
Inspect image assets, build transforms, CMS output, and rendered markup. Flag photos above the documented file-size thresholds, hero images that exceed budget without justification, and image pipelines that ship original uploads instead of compressed responsive variants.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/images/image-file-size
常见问题
照片建议的大小上限是多少?
这项技能建议照片低于 200 KB,全宽首图低于 400 KB。
为什么建议 WebP 和 AVIF?
这项技能指出,在相近画质下,它们通常比 JPEG 小得多。
它也检查尺寸吗?
这项技能建议将文件大小问题与尺寸问题区分开,以找到真正的原因。
详情
作者的原始描述
Use when auditing the image pipeline, static assets in `public/`, CMS-managed media, or image CDN transforms. Separate file-size problems from dimension mismatches so you can tell whether the issue is compression, format choice, or responsive delivery.
热度
- GitHub 星标
- 75k
- 排名
- #2884
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。