Creating silky-smooth 60 frames-per-second (fps) animations requires understanding the browser rendering pipeline. Animating the wrong CSS properties causes jank, dropped frames, and high CPU usage.
The Browser Rendering Pipeline
When styles change, the browser executes up to three pipeline stages:
1. Layout (Reflow) ──> Recalculates geometry (width, height, margin, top)
|
v
2. Paint (Repaint) ──> Fills pixels (color, background, box-shadow)
|
v
3. Composite (GPU) ──> Combines GPU layers (transform, opacity)
- Layout triggers:
width,height,padding,margin,top,left. AVOID ANIMATING THESE! They force the CPU to recalculate page geometry for all surrounding elements. - Paint triggers:
background-color,box-shadow,border-color. Better, but still uses CPU rasterization. - Composite triggers (60fps GPU acceleration):
transformandopacity. These bypass Layout and Paint entirely, executing directly on the GPU!
High-Performance Transitions & Easing
.card-interactive {
/* Animate ONLY transform and opacity */
transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
box-shadow 250ms ease;
will-change: transform; /* Hints to GPU to promote element to its own layer */
}
.card-interactive:hover {
/* Smooth elevation without layout reflow */
transform: translateY(-4px) scale(1.01);
box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12);
}
Understanding Easing Curves
ease: Default; slow start, fast middle, slow end.linear: Constant velocity. Ideal for infinite spinners.cubic-bezier(x1, y1, x2, y2): Custom physics curves.cubic-bezier(0.16, 1, 0.3, 1)creates crisp, professional "spring/snap" ease-outs used in iOS and macOS.
3D Transforms & Perspective
.card-scene {
perspective: 1000px; /* Establishes 3D depth field */
}
.card-flipper {
transform-style: preserve-3d;
transition: transform 600ms cubic-bezier(0.4, 0, 0.2, 1);
}
.card-scene:hover .card-flipper {
transform: rotateY(180deg); /* Flips card in 3D space */
}
Exercises
- Benchmark a transition animating
left: 100pxversustransform: translateX(100px)using the Chrome DevTools Performance panel. - Implement an accordion collapse animation using
transform: scaleY()instead of animatingmax-height. - Explain why excessive use of
will-change: transformacross hundreds of elements consumes excessive GPU VRAM.