跳到正文
Skillpedia
图片与图标75k · #2944

modern-format

它能做什么

这项技能找出使用旧格式的图片,并建议使用 WebP 或 AVIF 等现代格式,它们的文件更小。适用于希望网站加载更快、流量更少的网页制作者。

适用场景

  • ✓当你请智能体让网站上的图片加载更快的时候。
  • ✓当页面因照片和图形文件较大而感觉很慢的时候。
  • ✓当你为网站准备图片,并希望使用带安全备用方案的现代格式的时候。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/modern-format/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2944
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能