cumulative-layout-shift
它能做什么
这项技能查找加载过程中会移动的页面元素,例如把文字向下推的图片或广告。适合希望页面稳定、可预测的网页制作者。
适用场景
- ✓当访客反映按钮在点击前刚好移动时。
- ✓当图片或广告出现后,页面文字向下跳动时。
- ✓当你希望在 Google 的页面速度检查中获得更好的分数时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/cumulative-layout-shift/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“为什么我页面上的文字在加载时会跳来跳去?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查页面如何为图片、嵌入内容和其他内容预留空间,然后建议提前设置尺寸,使内容之后不再发生位移。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Minimize cumulative layout shift
Layout shifts cause accidental clicks, reading disruption, and user frustration—a good CLS score ensures content stays where users expect it.
Quick Reference
- CLS measures visual stability—target score below 0.1
- Always set width/height on images and embeds
- Reserve space for ads, banners, and dynamic content
- Use transform animations instead of layout-changing properties
Check
Measure CLS using Lighthouse or PageSpeed Insights. Verify score is below 0.1 for good visual stability.
Fix
Reserve space for images/embeds with dimensions, use font-display strategies, and avoid injecting content above existing content.
Explain
Explain how CLS measures visual stability and why unexpected layout shifts frustrate users and cause accidental clicks.
Code Review
Review the routes, assets, and loading behavior that affect Minimize cumulative layout shift. Flag exact files, requests, or rendering steps that add unnecessary network, CPU, or layout cost, and describe the measurement method used to confirm the issue.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/cumulative-layout-shift
常见问题
什么是布局偏移?
它是指内容在已经显示到屏幕上之后又发生移动,这会导致访客点错东西。
这个问题如何衡量?
这项技能建议使用 Lighthouse 或 PageSpeed Insights,并以低于 0.1 为目标。
这项技能也能解决加载缓慢的问题吗?
它关注的是加载过程中的移动,而不是整体速度。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Minimize cumulative layout shift. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #2804
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。