Compositor-Only Properties: transform and opacity
You'll learn why animating transform and opacity is dramatically faster than other properties—and how the GPU comes to the rescue.
Why These Two Properties Are Special
When you animate most CSS properties—like width, height, background-color, or top—the browser must recalculate layout (where elements sit) and repaint (what pixels look like). This happens on the main thread, which is also juggling your JavaScript, React updates, and user interactions.
But transform and opacity are different. They bypass layout and paint entirely. The browser hands them off to the compositor thread and the GPU, which can animate these properties independently without blocking the main thread.
How It Works
Think of your webpage as layers in Photoshop. When you animate transform (translate, scale, rotate) or opacity, the browser creates a separate layer for that element. The compositor thread can slide, fade, or spin that layer around like a transparency sheet—without redrawing any pixels or recalculating where other elements should be.
Other properties force the browser to:
- Layout (recalculate positions)
- Paint (redraw pixels)
- Composite (merge layers)
Compositor-only properties skip straight to step 3—on a separate thread with GPU acceleration.
Why This Matters in React
When animating React components (with CSS transitions, Framer Motion, or GSAP), choosing transform and opacity keeps animations smooth even during heavy re-renders or slow JavaScript execution. Your animation runs at 60fps on the GPU while React does its thing on the main thread.
Key Takeaway: Always prefer animating transform (for movement/scale/rotation) and opacity (for fading) over properties like left, width, or background-color—they run on the GPU compositor, bypassing layout and paint for buttery-smooth performance.