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

image-optimization

它能做什么

这项技能审查项目中的所有图片,并检查每张图片是否存在常见的网页性能问题。适用于希望页面快速、稳定的开发者和设计师。

适用场景

  • ✓当你的页面加载缓慢,且图片可能是主要原因的时候。
  • ✓当图片缺少尺寸属性或懒加载设置的时候。
  • ✓当你希望在上线前全面审查图片处理方式的时候。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“请审查我网站上的所有图片,并修复性能问题。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查每张图片的格式、响应式尺寸、宽度和高度、懒加载以及文件大小。它会按严重程度对问题分组,并建议修复方法,例如使用带 WebP 或 AVIF 的 picture 元素和 srcset 尺寸。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Optimize all images for web

Images typically account for 50%+ of page weight. Unoptimized images cause slow load times, wasted bandwidth, poor Core Web Vitals scores, and frustrated users—especially on mobile networks.

Quick Reference

  • Use modern formats: AVIF > WebP > JPEG/PNG
  • Compress images to 80% quality for photos
  • Always provide responsive srcset for different screen sizes
  • Use <picture> element for format fallbacks

Check

Scan this codebase for all image assets and <img> elements. For each image, verify: 1) Format is appropriate (WebP/AVIF for photos, SVG for icons, PNG only for transparency). 2) Responsive srcset and sizes attributes exist for images > 100px wide. 3) width/height attributes are present to prevent layout shift. 4) loading='lazy' is set for below-fold images. 5) File sizes are reasonable (< 200KB for photos, < 50KB for graphics). Report issues grouped by severity with file paths.

Fix

For each image optimization issue found: 1) Convert JPEG/PNG photos to WebP with AVIF fallback using <picture> element. 2) Add srcset with 400w, 800w, 1200w, 1600w variants and appropriate sizes attribute. 3) Add explicit width/height attributes matching aspect ratio. 4) Add loading='lazy' to images below the fold, keep priority images without lazy loading. 5) Compress images to 80% quality for photos, 60% for AVIF. 6) Use SVG for icons and logos. Show the corrected HTML with optimized image markup.

Explain

Explain the impact of image optimization on Core Web Vitals, specifically how unoptimized images affect Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS). Cover the compression differences between AVIF, WebP, and JPEG formats, when to use each, and browser support considerations. Describe how srcset and sizes work together to serve appropriately-sized images, and why width/height attributes prevent layout shift. Include bandwidth savings calculations and loading performance improvements.

Code Review

Review image assets, markup, and delivery configuration related to Optimize all images for web. 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/image-optimization

常见问题

每张图片都应该懒加载吗?

不应该。这项技能指出,应保留优先图片(例如页面顶部的主图)不做懒加载。

它推荐什么格式?

它首先推荐 AVIF,其次是 WebP,并以 JPEG 或 PNG 作为备用,图标和标志则使用 SVG。

为什么要添加宽度和高度?

这项技能指出,明确的尺寸可以防止页面加载时发生布局偏移。

详情

作者的原始描述

Use when reviewing image assets, markup, and CDN or build transforms related to Optimize all images for web. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能