GSAP Motion
GPU-Accelerated GSAP Animation Without the Jank
GPU-accelerated GSAP animation means moving elements with transform and opacity so the browser composites frames on the GPU instead of recalculating layout and repainting. In my builds I animate x, y, scale, rotation and autoAlpha, set force3D deliberately, add will-change only to elements about to move, then remove it. Animating top or left forces layout and paint every frame and shows up as jank.
What GPU-accelerated GSAP animation actually means
GPU-accelerated GSAP animation is less about GSAP and more about which CSS properties you ask it to change. GSAP runs on requestAnimationFrame through gsap.ticker and writes inline styles each frame; the browser then decides whether that frame needs layout, paint or only compositing. When you animate transform and opacity on an element that already has its own compositor layer, the cached texture is simply transformed on the GPU — no geometry recalculation, no repaint. The render pipeline is style, layout, paint, composite; the fast path skips the middle two. That distinction matters on a mid-range Android phone, where a single forced layout per frame can turn a 200ms reveal into visible stutter and push interaction latency toward the 200ms INP threshold. I treat the property list as the performance budget, not the tween duration.
- GSAP writes inline styles on rAF; the browser chooses layout, paint or composite
- Compositor-only properties: transform and opacity
- Pipeline: style → layout → paint → composite; skip layout and paint
- Target smooth frames on mid-range Android, not just desktop
Animate transform and opacity, nothing else
The safe list is short: x, y, xPercent, yPercent, scale, scaleX, scaleY, rotation and opacity. GSAP maps these to a single transform matrix, and the compositor can apply that matrix to an already painted layer. Use autoAlpha when a fading element also needs to stop capturing clicks and keyboard focus — it animates opacity and sets visibility: hidden at zero. Set the starting state with gsap.set before the tween runs so the first frame does not recalculate geometry. For pointer-following effects, gsap.quickTo or gsap.quickSetter beats creating a new tween on every mousemove. Everything outside the safe list has a cost: width, height, margin, padding, font-size and flex ordering all reflow the document; box-shadow, background-color and filter repaint pixels. Some of those can be composited in one browser and not another, so I assume they are expensive until a trace proves otherwise.
- x, y, xPercent, yPercent for position; scale and rotation for size and turn
- autoAlpha instead of opacity when the element must stop capturing clicks
- gsap.set the starting transform before the tween begins
- quickTo or quickSetter for pointer-driven updates
- Avoid width, height, margin, top, left, box-shadow and filter in loops
Why top and left animations repaint
top and left are layout properties. Change either one and the browser must recompute the position of the element box, then repaint the affected region, then recomposite the result — three stages per frame, repeated sixty times a second. Moving the same element with transform: translate3d(x, y, 0) leaves its layout box exactly where it was; the GPU draws the same texture at a new offset, so only the composite stage runs. Positioning the element absolutely stops siblings from reflowing, but it does not stop the layout pass for that element — left is still a layout trigger. This is why a supposedly cheap absolute-positioned slide-in can still stutter. In Chrome DevTools Performance, a top/left tween shows a repeating pattern of purple Layout and green Paint events; a transform tween shows mainly compositor work. Adding will-change will not rescue it: layer promotion moves the repainted pixels to a layer, it does not remove the layout pass.
- top/left change the layout box → Layout → Paint → Composite every frame
- transform: translate3d(x, y, 0) changes only the compositor offset
- DevTools Performance: repeated Layout and Paint events are the fingerprint
- will-change does not make a layout property cheap
- Absolute positioning removes siblings from reflow, not the element layout pass
force3D: what GSAP actually does
force3D is a GSAP setting that controls whether a transform is written with a 3D component, the classic way to get the browser to promote an element to its own compositor layer. The default is "auto": GSAP adds translate3d while the tween runs and removes it when the tween completes, so no permanent layer is kept after a one-off reveal. Setting force3D: true leaves the 3D transform in place, which helps continuously moving elements such as a ScrollTrigger scrub or a looping marquee; false forces 2D transforms. You can set it per tween or globally with gsap.config. Modern Chrome and Safari already promote animating transforms on their own, so the setting is less decisive than it once was; what matters more is not promoting hundreds of elements at once. In my builds I keep the auto default and opt into force3D: true only where an element moves for most of its time on the page.
- Default force3D: "auto" — 3D during the tween, reverted at completion
- force3D: true keeps translate3d in place permanently
- gsap.config({ force3D: true }) sets the site-wide default
- Every promoted layer costs GPU memory; avoid bulk enablement
will-change hygiene: promote, then release
will-change: transform tells the browser to prepare a layer before the animation starts, removing promotion cost from the first frame. It is a hint, not a permanent state. The mistake I see most often is declaring will-change on every card in a global stylesheet: each hint can create a compositor layer, and hundreds of layers consume GPU memory, increase raster work and can drop subpixel text antialiasing on some platforms. The result is slower than no hint at all. I add the hint just before motion — on pointerenter, on ScrollTrigger onEnter, or when a section becomes visible — and remove it in onComplete, onLeaveBack or after a resize settles. The clearProps option with willChange removes the inline property cleanly. The older translateZ(0) and backface-visibility: hidden hacks promote permanently and deserve the same caution. Treat layer promotion as a scarce resource you borrow and return.
- Add will-change shortly before the tween, not in a global stylesheet
- Remove it in onComplete or ScrollTrigger onLeaveBack
- Each layer consumes GPU memory and can soften text antialiasing
- clearProps: "willChange" removes the inline hint after the reveal
Verify the fast path in Chrome DevTools
I do not call an animation optimized until I have watched a trace. In Chrome DevTools Performance, record a few seconds of the tween and inspect the Main thread: a compositor-only animation shows almost no Layout or Paint blocks, while a top/left tween paints a repeating pattern of them. Enable Paint flashing under Rendering — if the moving element lights up green on every frame, it is being repainted. The Layers panel shows how many layers exist, why each was promoted and an estimated memory cost; that is where a will-change leak becomes obvious. I then throttle CPU by 4x and test on a mid-range Android phone, keeping frames inside roughly 16.7ms at 60Hz. After release I check field INP in CrUX against the 200ms threshold, because lab smoothness does not guarantee responsive real visits.
- Performance panel: no repeating Layout or Paint events during the tween
- Rendering → Paint flashing: the moving area should not flash green
- Layers panel: count layers and check compositing reasons and memory
- Throttle CPU 4x and test on a mid-range Android device
- Confirm field INP stays under 200ms after release
Where I use this in WordPress builds
In my WordPress and PHP builds I enqueue GSAP only on templates that animate — a project grid reveal or a scroll-driven header — instead of loading the library site-wide. ScrollTrigger handles scrubbed motion, and gsap.matchMedia lets me honor prefers-reduced-motion by serving a static end state instead of the tween. The trade-off is real: promoting a layer costs memory, and a promoted text block can lose subpixel antialiasing, so I avoid promoting large hero images or long copy unless a trace shows a benefit. I also release every will-change hint once a reveal finishes. I am Saif Al Jahan, a WordPress and PHP developer in Mymensingh, Bangladesh (GMT+6); webdev-saif.com documents how I pair GSAP motion with Core Web Vitals budgets rather than treating animation as an afterthought.
- Enqueue GSAP and ScrollTrigger only on templates that animate
- Use gsap.matchMedia to honor prefers-reduced-motion
- Avoid promoting large hero images or text-heavy blocks unless needed
- Release every layer hint once the reveal completes
Frequently asked questions
Does GSAP use the GPU automatically?
Not directly. GSAP writes inline styles on requestAnimationFrame through gsap.ticker; the browser decides whether each frame needs layout, paint or only compositing. You get the GPU path by animating compositor-friendly properties — transform and opacity — on an element with its own layer. Animate width or top instead and GSAP cannot help; the main thread still recalculates and repaints every frame.
Why is my GSAP animation laggy when I animate top or left?
Because top and left change layout geometry. Each frame invalidates the layout box, triggers a layout pass, repaints the affected region and then recomposites — work that repeats sixty times a second. Transform changes only the compositor offset, leaving the layout box untouched. Moving the element with position: absolute stops siblings from reflowing, but the layout pass for that element still happens. Use x and y in GSAP instead.
Should I set force3D: true on every tween?
No. The GSAP default, force3D: "auto", adds translate3d during the tween and removes it afterwards, which suits one-off reveals. Force true only for elements that move continuously, such as a ScrollTrigger scrub or an infinite loop; it keeps the layer alive and consumes GPU memory. Modern browsers already promote animating transforms, so blanket-enabling it on hundreds of elements often makes performance worse.
How long should will-change stay on an element?
Only for the window just before and during the motion. Add will-change: transform on pointerenter, focus, or ScrollTrigger onEnter, then remove it in onComplete or onLeaveBack — the clearProps option can do that. Leaving it permanently in CSS creates layers that consume GPU memory and may soften text. If the element is always moving, a permanent layer is justified; otherwise borrow it and give it back.
Is transform faster than opacity for animation?
Both are compositor properties, so neither forces layout or paint on its own. Transform moves an already painted texture; opacity blends it. The cost comes from layer size: fading a full-viewport layer still means blending a lot of pixels each frame. Use autoAlpha when a fading element should also stop receiving clicks and focus, since it sets visibility: hidden at zero.
How do reduced-motion preferences fit into GSAP animations?
With gsap.matchMedia. Register a "(prefers-reduced-motion: reduce)" condition and set the element to its final state with gsap.set instead of playing the tween, or use a shorter non-moving fade. Keep the same markup and layout so nothing shifts. I treat reduced motion as a first-class branch in the animation code, not a CSS afterthought that GSAP then overrides with inline styles.