动画性能优化技能包
GSAP Performance Skill
让 AI 写出 60fps 流畅的 GSAP 动画:用 transform、will-change、批量处理。
功能概览
让 AI 写出 60fps 流畅的 GSAP 动画:用 transform、will-change、批量处理。
- 动画卡顿,触发频繁的布局重排
- 动画 top/left 而不是 transform,性能差
- ScrollTrigger 入场动画在多元素时卡顿
- 移动端动画掉帧
使用场景
- 优化卡顿的网页动画到 60fps
- 用 ScrollTrigger.batch() 优化大量元素入场
- 合理设置 will-change 提示浏览器
- 排查动画性能瓶颈
适合谁用
- 遇到动画卡顿的前端开发者
- 做移动端动画的人
- 关注性能的站长
不适合谁
- 不做动画的人
- 完全不用 GSAP 的人
普通人版解释
用大白话说这个技能包解决「动画卡顿」的问题。AI 写动画时经常用 top/left 这种会触发重排的属性,导致移动端掉帧。装了这个技能包后,AI 会主动用 transform、合理设置 will-change、批量处理滚动入场,让动画保持 60fps 流畅,尤其在低端设备上也能跑得动。
专业版解释
给 Claude Code / Codex 用户GSAP Performance Skill 教 AI 写出高性能的 GSAP 动画。安装后,AI 会主动用 transform(x/y/scale/rotation)而不是 layout 属性(top/left/width/height)、合理使用 will-change、用 ScrollTrigger.batch() 批量处理滚动入场、避免触发布局重排。让动画保持 60fps 流畅,尤其在移动端和低端设备上。
安装方式
复制对应平台的命令到终端执行。安装前建议先确认来源和安全等级。
npx skills add https://github.com/greensock/gsap-skills
SKILL.md 预览
这是这个技能包的核心内容。默认折叠预览,确认后再复制或展开。
# GSAP Performance
## When to Use This Skill
Apply when optimizing GSAP animations for smooth 60fps, reducing layout/paint cost, or when the user asks about performance, jank, or best practices for fast animations.
**Related skills:** Build animations with **gsap-core** (transforms, autoAlpha) and **gsap-timeline**; for ScrollTrigger performance see **gsap-scrolltrigger**.
## Prefer Transform and Opacity
Animating **transform** (`x`, `y`, `scaleX`, `scaleY`, `rotation`, `rotationX`, `rotationY`, `skewX`, `skewY`) and **opacity** keeps work on the compositor and avoids layout and most paint. Avoid animating layout-heavy properties when a transform can achieve the same effect.
- ✅ Prefer: **x**, **y**, **scale**, **rotation**, **opacity**.
- ❌ Avoid when possible: **width**, **height**, **top**, **left**, **margin**, **padding** (they trigger layout and can cause jank).
GSAP’s **x** and **y** use transforms (translate) by default; use them instead of **left**/**top** for movement.
## will-change
Use **will-change** in CSS on elements that will animate. It hints the browser to promote the layer.
```css
will-change: transform;
```
## Batch Reads and Writes
GSAP batches updates internally. When mixing GSAP with direct DOM reads/writes or layout-dependent code, avoid interleaving reads and writes in a way that causes repeated layout thrashing. Prefer doing all reads first, then all writes (or let GSAP handle the writes in one go).
## Many Elements (Stagger, Lists)
- Use **stagger** instead of many separate tweens with manual delays when the animation is the same; it’s more efficient.
- For long lists, consider **virtualization** or animating only visible items; avoid creating hundreds of simultaneous tweens if it causes jank.
- Reuse timelines where possible; avoid creating new timelines every frame.
## Frequently updated properties (e.g. mouse followers)
Prefer **gsap.quickTo()** for properties that are updated often (e.g. mouse-follower x/y). It reuses a single tween instead of creating new tweens on each update.
```javascript
let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),
yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });
document.querySelector("#container").addEventListener("mousemove", (e) => {
xTo(e.pageX);
yTo(e.pageY);
});
```
## ScrollTrigger and Performance
- **pin: true** promotes the pinned element; pin only what’s needed.
- **scrub** with a small value (e.g. `scrub: 1`) can reduce work during scroll; test on low-end devices.
- Call **ScrollTrigger.refresh()** only when layout actually changes (e.g. after content load), not on every resize; debounce when possible.
## Reduce Simultaneous Work
- Pause or kill off-screen or inactive animations when they’re not visible (e.g. when the user navigates away).
- Avoid animating huge numbers of properties on many elements at once; simplify or sequence if needed.
## Best practices
- ✅ Animate **transform** and **opacity**; use **will-change** in CSS only on elements that animate.
- ✅ Use **stagger** instead of many separate tweens with manual delays when the animation is the same.
- ✅ Use **gsap.quickTo()** for frequently updated properties (e.g. mouse followers).
- ✅ Clean up or kill off-screen animations; call **ScrollTrigger.refresh()** when layout changes, debounced when possible.
## Do Not
- ❌ Animate **width**/ **height**/ **top**/ **left** for movement when **x**/ **y**/ **scale** can achieve the same look.
- ❌ Set **will-change** or **force3D** on every element “just in case”; use for elements that are actually animating.
- ❌ Create hundreds of overlapping tweens or ScrollTriggers without testing on low-end devices.
- ❌ Ignore cleanup; stray tweens and ScrollTriggers keep running and can hurt performance and correctness.如何使用
安装后,把下面的提示词直接发给 AI 即可触发这个技能包。
- 1.请使用动画性能优化技能包,帮我把这个卡顿的动画优化到 60fps。
- 2.请使用动画性能优化技能包,把这里的 top/left 动画改成 transform。
- 3.请使用动画性能优化技能包,用 ScrollTrigger.batch 优化这一长串列表的入场。
安全说明
技能包可能不只是提示词。请先查看下面的权限表,了解这个技能包会做什么。
| 权限项 | 状态 | 风险 |
|---|---|---|
| 是否包含脚本 | 否 | 无风险 |
| 是否会执行系统命令 | 否 | 无风险 |
| 是否会读取本地文件 | 否 | 无风险 |
| 是否会联网请求 | 否 | 无风险 |
| 是否适合新手安装 | 否 | 不建议新手 |
相关技能包

网页动画核心技能包
让 AI 正确使用 GSAP 核心 API:做网页动画、SVG 动画、React/Vue 动画时不再写错代码。

动画序列编排技能包
让 AI 正确编排多个动画的先后顺序:标题先入、副标题跟入、按钮最后入。

滚动动画技能包
让 AI 做对滚动联动的网页动画:视差、滚动进度、钉住章节、滚动触发入场。

React 动画技能包
让 AI 在 React / Next.js 里正确使用 GSAP:useGSAP hook、清理、SSR 不报错。

前端设计技能包
让 AI 做有辨识度的前端视觉设计:美学方向、字体、避免模板化的廉价感。

Web 组件构建技能包
让 AI 用 React、Tailwind、shadcn/ui 构建复杂的多组件 claude.ai HTML artifacts。