跳到正文
Skillpedia
网站与界面(前端)75k · #2722

animation-performance

它能做什么

这项技能检查 CSS 动画中会拖慢渲染的属性。适合希望网站动效流畅的开发者。

适用场景

  • ✓当网页上的 CSS 动画看起来卡顿或不流畅时。
  • ✓当样式表中的动画改变了尺寸、位置或外边距时。
  • ✓当你希望动画尊重减少动态效果的设置时。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“我的菜单滑入动画在手机上有卡顿。请帮我检查 CSS,并让它更流畅。”

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

工作原理

智能体会找出改变布局属性的动画,把它们改为 transform 和 opacity 的变化,并建议尊重减少动态效果的设置。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Use transform and opacity for animations

Animating layout properties (width, height, top, margin) triggers the full browser rendering pipeline on every frame — style recalculation, layout, paint, and composite. This runs on the main thread and competes with JavaScript. Animating transform and opacity skips layout and paint entirely and runs on a dedicated GPU thread, achieving smooth 60fps even when the main thread is busy.

Quick Reference

  • Only transform and opacity can be composited on the GPU without triggering layout
  • Use will-change: transform sparingly to promote an element to its own compositor layer
  • Prefer CSS transitions and animations over JavaScript animation libraries for simple effects
  • Respect prefers-reduced-motion to disable animations for users who need it

Check

Find CSS animations or transitions in this file that animate layout-triggering properties like top, left, width, height, or margin. Flag them for optimization.

Fix

Convert layout-triggering animations to use transform equivalents: position changes to translate(), size changes to scale().

Explain

Explain the browser rendering pipeline, why transform and opacity are performant for animation, and how the GPU compositor works.

Code Review

Review stylesheets, component styles, and responsive states related to Use transform and opacity for animations. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/css/animation-performance

常见问题

为什么 transform 和 opacity 更流畅?

这项技能说明,它们可以由图形处理器处理,不会在每一帧都触发布局和绘制。

will-change 有什么作用?

这项技能说明应谨慎使用它,为元素提供独立的渲染层。

简单的效果应该使用动画库吗?

这项技能建议,对于简单的效果,应优先使用 CSS 过渡和动画,而不是 JavaScript 动画库。

详情

作者的原始描述

Use when reviewing stylesheets, component styles, and responsive behavior related to Use transform and opacity for animations. Check the rendered layout across breakpoints and interaction states before proposing a fix.

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能