Performance is critical for animations. Janky, stuttering animations create a poor user experience and make your application feel slow. This guide covers techniques to keep animations smooth and performant.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Aduwoayooluwa/animations/llms.txt
Use this file to discover all available pages before exploring further.
Understanding FPS (frames per second)
Smooth animations run at 60 FPS (frames per second), which means the browser needs to render a new frame every 16.67ms. If any frame takes longer than this, you’ll see stuttering.The render pipeline
Every frame, the browser may need to:- JavaScript - Execute JS code
- Style - Calculate which CSS rules apply
- Layout - Calculate element positions and sizes
- Paint - Fill in pixels (text, colors, images)
- Composite - Draw layers in the correct order
FPS monitoring
The Animation Playground includes a real-time FPS monitor:Hardware acceleration
Modern browsers can offload certain animations to the GPU (Graphics Processing Unit), which is much faster than the CPU for visual operations.Properties that trigger GPU acceleration
Transform and opacity are the only properties guaranteed to be GPU-accelerated:Performance comparison example
From the Animation Playground:With 100 elements, using
transform maintains 60 FPS while top/left drops to 20-30 FPS.The will-change property
will-change tells the browser which properties will animate, allowing it to optimize ahead of time.
When to use will-change
- An element will animate frequently
- Performance issues exist without it
- Animation happens in response to user interaction
- Applying to many elements (creates too many layers)
- The animation is one-time or rare
- You haven’t measured a performance issue
Proper will-change usage
RequestAnimationFrame vs CSS
Choose the right animation approach for your use case.CSS animations/transitions
Pros:- Run on a separate thread from JavaScript
- Automatically optimized by the browser
- Simple syntax for common animations
- Better battery life on mobile
- Limited control over playback
- Harder to sync with JavaScript logic
- Can’t animate all properties
RequestAnimationFrame
Pros:- Complete control over animation logic
- Can animate any value (not just CSS properties)
- Easy to sync with other JavaScript
- Pause/resume/seek capabilities
- Runs on main thread (competes with JavaScript)
- More code required
- Can block if JavaScript is busy
Framer Motion (best of both)
Framer Motion automatically chooses the best approach:Common performance pitfalls
Pitfall 1: Animating layout properties
Bad:Pitfall 2: Too many simultaneous animations
Bad:Pitfall 3: Large paint areas
Bad:Pitfall 4: Not cleaning up animations
Bad:Performance tips from the Animation Playground
Here are the key tips displayed in the app:- Use transform and opacity
- Promote to new layer
- Debounce scroll handlers
- Reduce paint area
These properties are optimized by browsers and can be hardware accelerated.
Measuring performance
Chrome DevTools Performance tab
- Open DevTools (F12)
- Go to Performance tab
- Click Record
- Trigger your animation
- Stop recording
- Look for:
- Long tasks (red bars) - JavaScript blocking the main thread
- Frames - Should be under 16ms each
- Paint and Layout - Should be minimal during animation
Rendering panel
- Open DevTools
- Press Ctrl+Shift+P (Cmd+Shift+P on Mac)
- Type “Show Rendering”
- Enable:
- Paint flashing - Green highlights show repainted areas
- FPS meter - Real-time FPS display
- Layout Shift Regions - Shows layout recalculations
Use the Chrome DevTools Performance and Rendering panels to identify and fix animation performance issues.
Best practices summary
- Animate only transform and opacity - These are GPU-accelerated
- Use CSS for simple animations - Better performance than JavaScript
- Use requestAnimationFrame for complex animations - Better than setTimeout/setInterval
- Limit will-change usage - Only when needed
- Reduce simultaneous animations - Stagger or limit count
- Minimize paint areas - Smaller elements = faster repaints
- Clean up animations - Cancel animations when components unmount
- Test on real devices - Mobile performance differs from desktop
- Monitor FPS - Aim for consistent 60 FPS
- Use DevTools - Measure before optimizing