fixing-motion-performance
Skills2113/26/2026
Version 2
PublishedUpdated via agex push
Created 3/26/2026
Changes
v1 → v2
| 1 | 1 | --- | |
| 2 | 2 | name: fixing-motion-performance | |
| 3 | 3 | description: Fix animation performance issues. | |
| 4 | 4 | --- | |
| 5 | 5 | ||
| 6 | 6 | # fixing-motion-performance | |
| 7 | 7 | ||
| 8 | 8 | Fix animation performance issues. | |
| 9 | 9 | ||
| 10 | 10 | ## how to use | |
| 11 | 11 | ||
| 12 | 12 | - `/fixing-motion-performance` | |
| 13 | 13 | Apply these constraints to any UI animation work in this conversation. | |
| 14 | 14 | ||
| 15 | 15 | - `/fixing-motion-performance <file>` | |
| 16 | 16 | Review the file against all rules below and report: | |
| 17 | 17 | - violations (quote the exact line or snippet) | |
| 18 | 18 | - why it matters (one short sentence) | |
| 19 | 19 | - a concrete fix (code-level suggestion) | |
| 20 | 20 | ||
| 21 | 21 | Do not migrate animation libraries unless explicitly requested. Apply rules within the existing stack. | |
| 22 | 22 | ||
| 23 | 23 | ## when to apply | |
| 24 | 24 | ||
| 25 | 25 | Reference these guidelines when: | |
| 26 | 26 | - adding or changing UI animations (CSS, WAAPI, Motion, rAF, GSAP) | |
| 27 | 27 | - refactoring janky interactions or transitions | |
| 28 | 28 | - implementing scroll-linked motion or reveal-on-scroll | |
| 29 | 29 | - animating layout, filters, masks, gradients, or CSS variables | |
| 30 | 30 | - reviewing components that use will-change, transforms, or measurement | |
| 31 | 31 | ||
| 32 | 32 | ## rendering steps glossary | |
| 33 | 33 | ||
| 34 | 34 | - composite: transform, opacity | |
| 35 | 35 | - paint: color, borders, gradients, masks, images, filters | |
| 36 | 36 | - layout: size, position, flow, grid, flex | |
| 37 | 37 | ||
| 38 | 38 | ## rule categories by priority | |
| 39 | 39 | ||
| 40 | 40 | | priority | category | impact | | |
| 41 | 41 | |----------|----------|--------| | |
| 42 | 42 | | 1 | never patterns | critical | | |
| 43 | 43 | | 2 | choose the mechanism | critical | | |
| 44 | 44 | | 3 | measurement | high | | |
| 45 | 45 | | 4 | scroll | high | | |
| 46 | 46 | | 5 | paint | medium-high | | |
| 47 | 47 | | 6 | layers | medium | | |
| 48 | 48 | | 7 | blur and filters | medium | | |
| 49 | 49 | | 8 | view transitions | low | | |
| 50 | 50 | | 9 | tool boundaries | critical | | |
| 51 | 51 | ||
| 52 | 52 | ## quick reference | |
| 53 | 53 | ||
| 54 | 54 | ### 1. never patterns (critical) | |
| 55 | 55 | ||
| 56 | 56 | - do not interleave layout reads and writes in the same frame | |
| 57 | 57 | - do not animate layout continuously on large or meaningful surfaces | |
| 58 | 58 | - do not drive animation from scrollTop, scrollY, or scroll events | |
| 59 | 59 | - no requestAnimationFrame loops without a stop condition | |
| 60 | 60 | - do not mix multiple animation systems that each measure or mutate layout | |
| 61 | 61 | ||
| 62 | 62 | ### 2. choose the mechanism (critical) | |
| 63 | 63 | ||
| 64 | 64 | - default to transform and opacity for motion | |
| 65 | 65 | - use JS-driven animation only when interaction requires it | |
| 66 | 66 | - paint or layout animation is acceptable only on small, isolated surfaces | |
| 67 | 67 | - one-shot effects are acceptable more often than continuous motion | |
| 68 | 68 | - prefer downgrading technique over removing motion entirely | |
| 69 | 69 | ||
| 70 | 70 | ### 3. measurement (high) | |
| 71 | 71 | ||
| 72 | 72 | - measure once, then animate via transform or opacity | |
| 73 | 73 | - batch all DOM reads before writes | |
| 74 | 74 | - do not read layout repeatedly during an animation | |
| 75 | 75 | - prefer FLIP-style transitions for layout-like effects | |
| 76 | 76 | - prefer approaches that batch measurement and writes | |
| 77 | 77 | ||
| 78 | 78 | ### 4. scroll (high) | |
| 79 | 79 | ||
| 80 | 80 | - prefer Scroll or View Timelines for scroll-linked motion when available | |
| 81 | 81 | - use IntersectionObserver for visibility and pausing | |
| 82 | 82 | - do not poll scroll position for animation | |
| 83 | 83 | - pause or stop animations when off-screen | |
| 84 | 84 | - scroll-linked motion must not trigger continuous layout or paint on large surfaces | |
| 85 | 85 | ||
| 86 | 86 | ### 5. paint (medium-high) | |
| 87 | 87 | ||
| 88 | 88 | - paint-triggering animation is allowed only on small, isolated elements | |
| 89 | 89 | - do not animate paint-heavy properties on large containers | |
| 90 | 90 | - do not animate CSS variables for transform, opacity, or position | |
| 91 | 91 | - do not animate inherited CSS variables | |
| 92 | 92 | - scope animated CSS variables locally and avoid inheritance | |
| 93 | 93 | ||
| 94 | 94 | ### 6. layers (medium) | |
| 95 | 95 | ||
| 96 | 96 | - compositor motion requires layer promotion, never assume it | |
| 97 | 97 | - use will-change temporarily and surgically | |
| 98 | 98 | - avoid many or large promoted layers | |
| 99 | 99 | - validate layer behavior with tooling when performance matters | |
| 100 | 100 | ||
| 101 | 101 | ### 7. blur and filters (medium) | |
| 102 | 102 | ||
| 103 | 103 | - keep blur animation small (<=8px) | |
| 104 | 104 | - use blur only for short, one-time effects | |
| 105 | 105 | - never animate blur continuously | |
| 106 | 106 | - never animate blur on large surfaces | |
| 107 | 107 | - prefer opacity and translate before blur | |
| 108 | 108 | ||
| 109 | 109 | ### 8. view transitions (low) | |
| 110 | 110 | ||
| 111 | 111 | - use view transitions only for navigation-level changes | |
| 112 | 112 | - avoid view transitions for interaction-heavy UI | |
| 113 | 113 | - avoid view transitions when interruption or cancellation is required | |
| 114 | 114 | - treat size changes as potentially layout-triggering | |
| 115 | 115 | ||
| 116 | 116 | ### 9. tool boundaries (critical) | |
| 117 | 117 | ||
| 118 | 118 | - do not migrate or rewrite animation libraries unless explicitly requested | |
| 119 | 119 | - apply these rules within the existing animation system | |
| 120 | 120 | - never partially migrate APIs or mix styles within the same component | |
| 121 | 121 | ||
| 122 | 122 | ## review guidance | |
| 123 | 123 | ||
| 124 | 124 | - enforce critical rules first (never patterns, tool boundaries) | |
| 125 | 125 | - choose the least expensive rendering work that matches the intent | |
| 126 | 126 | - for any non-default choice, state the constraint that justifies it (surface size, duration, or interaction requirement) | |
| 127 | 127 | - when reviewing, prefer actionable notes and concrete alternatives over theory |
Action Skill
---
name: fixing-motion-performance
description: Fix animation performance issues.
---
# fixing-motion-performance
Fix animation performance issues.
## how to use
- `/fixing-motion-performance`
Apply these constraints to any UI animation work in this conversation.
- `/fixing-motion-performance <file>`
Review the file against all rules below and report:
- violations (quote the exact line or snippet)
- why it matters (one short sentence)
- a concrete fix (code-level suggestion)
Do not migrate animation libraries unless explicitly requested. Apply rules within the existing stack.
## when to apply
Reference these guidelines when:
- adding or changing UI animations (CSS, WAAPI, Motion, rAF, GSAP)
- refactoring janky interactions or transitions
- implementing scroll-linked motion or reveal-on-scroll
- animating layout, filters, masks, gradients, or CSS variables
- reviewing components that use will-change, transforms, or measurement
## rendering steps glossary
- composite: transform, opacity
- paint: color, borders, gradients, masks, images, filters
- layout: size, position, flow, grid, flex
## rule categories by priority
| priority | category | impact |
|----------|----------|--------|
| 1 | never patterns | critical |
| 2 | choose the mechanism | critical |
| 3 | measurement | high |
| 4 | scroll | high |
| 5 | paint | medium-high |
| 6 | layers | medium |
| 7 | blur and filters | medium |
| 8 | view transitions | low |
| 9 | tool boundaries | critical |
## quick reference
### 1. never patterns (critical)
- do not interleave layout reads and writes in the same frame
- do not animate layout continuously on large or meaningful surfaces
- do not drive animation from scrollTop, scrollY, or scroll events
- no requestAnimationFrame loops without a stop condition
- do not mix multiple animation systems that each measure or mutate layout
### 2. choose the mechanism (critical)
- default to transform and opacity for motion
- use JS-driven animation only when interaction requires it
- paint or layout animation is acceptable only on small, isolated surfaces
- one-shot effects are acceptable more often than continuous motion
- prefer downgrading technique over removing motion entirely
### 3. measurement (high)
- measure once, then animate via transform or opacity
- batch all DOM reads before writes
- do not read layout repeatedly during an animation
- prefer FLIP-style transitions for layout-like effects
- prefer approaches that batch measurement and writes
### 4. scroll (high)
- prefer Scroll or View Timelines for scroll-linked motion when available
- use IntersectionObserver for visibility and pausing
- do not poll scroll position for animation
- pause or stop animations when off-screen
- scroll-linked motion must not trigger continuous layout or paint on large surfaces
### 5. paint (medium-high)
- paint-triggering animation is allowed only on small, isolated elements
- do not animate paint-heavy properties on large containers
- do not animate CSS variables for transform, opacity, or position
- do not animate inherited CSS variables
- scope animated CSS variables locally and avoid inheritance
### 6. layers (medium)
- compositor motion requires layer promotion, never assume it
- use will-change temporarily and surgically
- avoid many or large promoted layers
- validate layer behavior with tooling when performance matters
### 7. blur and filters (medium)
- keep blur animation small (<=8px)
- use blur only for short, one-time effects
- never animate blur continuously
- never animate blur on large surfaces
- prefer opacity and translate before blur
### 8. view transitions (low)
- use view transitions only for navigation-level changes
- avoid view transitions for interaction-heavy UI
- avoid view transitions when interruption or cancellation is required
- treat size changes as potentially layout-triggering
### 9. tool boundaries (critical)
- do not migrate or rewrite animation libraries unless explicitly requested
- apply these rules within the existing animation system
- never partially migrate APIs or mix styles within the same component
## review guidance
- enforce critical rules first (never patterns, tool boundaries)
- choose the least expensive rendering work that matches the intent
- for any non-default choice, state the constraint that justifies it (surface size, duration, or interaction requirement)
- when reviewing, prefer actionable notes and concrete alternatives over theory