modern-format
它能做什么
这项技能找出使用旧格式的图片,并建议使用 WebP 或 AVIF 等现代格式,它们的文件更小。适用于希望网站加载更快、流量更少的网页制作者。
适用场景
- ✓当你请智能体让网站上的图片加载更快的时候。
- ✓当页面因照片和图形文件较大而感觉很慢的时候。
- ✓当你为网站准备图片,并希望使用带安全备用方案的现代格式的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/modern-format/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我网站的图片加载很慢。请帮我转换为现代格式,并更新代码。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会扫描图片标签和背景图片中的 JPEG 和 PNG 文件。它会帮助生成 WebP 或可选的 AVIF 版本,并把图片包裹在 picture 元素中,为不支持新格式的旧浏览器提供备用方案。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use modern image formats (WebP, AVIF)
Images are typically 50%+ of page weight. Switching from JPEG to WebP alone reduces transfer sizes by 25-35% with no visible quality change, directly improving Largest Contentful Paint (LCP) and saving bandwidth for users on mobile data plans. These savings compound across every visitor and every image on the site.
Quick Reference
- WebP is ~25-35% smaller than JPEG at equivalent quality (per web.dev)
- AVIF is ~40-50% smaller than JPEG at equivalent quality (per web.dev)
- Use
<picture>with<source type="image/avif">and<source type="image/webp">plus an<img>fallback - WebP has 97%+ global browser support; AVIF is supported in all modern browsers as of 2023
Check
Scan all <img> elements and CSS background-image declarations in this codebase. Identify: 1) Any <img src> pointing to .jpg, .jpeg, or .png files (not served via a CDN that auto-negotiates format). 2) Any <picture> elements that lack <source type="image/webp"> or <source type="image/avif"> entries. 3) Any CSS background images using JPEG or PNG when a WebP equivalent could be used. Report each finding with file path and line number.
Fix
For each image not using modern formats: 1) Convert to WebP at 80% quality using Squoosh or Sharp. 2) Optionally also generate AVIF at 60% quality for browsers that support it. 3) Wrap the original <img> in a <picture> element and add <source type="image/avif"> and <source type="image/webp"> entries with the new files. 4) Keep the original JPEG/PNG as the <img src> fallback. For CSS background images, use a @supports (background-image: url('.webp')) { } query to serve WebP to supporting browsers.
Explain
Explain the compression advantages of WebP and AVIF over JPEG and PNG. According to web.dev, WebP lossless images are 26% smaller than PNG and WebP lossy images are 25-35% smaller than JPEG at equivalent visual quality. AVIF offers further improvements: roughly 40-50% smaller than equivalent JPEG. Explain browser support: WebP has 97%+ global browser support as of 2024. AVIF is supported in Chrome 85+, Firefox 93+, and Safari 16.4+. The <picture> element with fallbacks means there is no risk in adopting these formats today.
Code Review
Review image assets, markup, and delivery configuration related to Use modern image formats (WebP, AVIF). 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/modern-format
常见问题
WebP 图片真的小很多吗?
这项技能指出,在相近画质下,WebP 大约比 JPEG 小 25% 到 35%,而 AVIF 可能更小。
旧浏览器还能显示图片吗?
可以。picture 元素使用 img 作为备用,因此不支持新格式的浏览器仍能显示图片。
这会影响加载速度吗?
这项技能指出,更小的图片可以改善 Largest Contentful Paint,并减少流量消耗。
详情
作者的原始描述
Use when reviewing image assets, markup, and CDN or build transforms related to Use modern image formats (WebP, AVIF). Check encoded size, rendered size, loading strategy, and above-the-fold impact together.
热度
- GitHub 星标
- 75k
- 排名
- #2944
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。