Skill岛
返回技能包商店

动画性能优化技能包

已实测

GSAP Performance Skill

让 AI 写出 60fps 流畅的 GSAP 动画:用 transform、will-change、批量处理。

来源仓库下载 SKILL.md
支持平台
Claude CodeCursorCodex
安全等级
低风险
安装难度
需要基础命令行
最后验证
2026年7月2日
来源仓库下载 SKILL.md
01/功能概览

功能概览

让 AI 写出 60fps 流畅的 GSAP 动画:用 transform、will-change、批量处理。

  • 动画卡顿,触发频繁的布局重排
  • 动画 top/left 而不是 transform,性能差
  • ScrollTrigger 入场动画在多元素时卡顿
  • 移动端动画掉帧
02/使用场景

使用场景

  • 优化卡顿的网页动画到 60fps
  • 用 ScrollTrigger.batch() 优化大量元素入场
  • 合理设置 will-change 提示浏览器
  • 排查动画性能瓶颈
03/适合人群

适合谁用

  • 遇到动画卡顿的前端开发者
  • 做移动端动画的人
  • 关注性能的站长
04/不适合人群

不适合谁

  • 不做动画的人
  • 完全不用 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 流畅,尤其在移动端和低端设备上。

07/安装方式

安装方式

复制对应平台的命令到终端执行。安装前建议先确认来源和安全等级。

安装命令
npx skills add https://github.com/greensock/gsap-skills
08/SKILL.md 预览

SKILL.md 预览

这是这个技能包的核心内容。默认折叠预览,确认后再复制或展开。

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.
09/使用示例

如何使用

安装后,把下面的提示词直接发给 AI 即可触发这个技能包。

使用示例(直接发给 AI)
  • 1.请使用动画性能优化技能包,帮我把这个卡顿的动画优化到 60fps。
  • 2.请使用动画性能优化技能包,把这里的 top/left 动画改成 transform。
  • 3.请使用动画性能优化技能包,用 ScrollTrigger.batch 优化这一长串列表的入场。
10/安全说明

安全说明

技能包可能不只是提示词。请先查看下面的权限表,了解这个技能包会做什么。

权限项状态风险
是否包含脚本无风险
是否会执行系统命令无风险
是否会读取本地文件无风险
是否会联网请求无风险
是否适合新手安装不建议新手
低风险
可以放心安装使用,适合所有用户。
11/相关技能包

相关技能包

查看全部