Crafting High-Performance GSAP Animations That Don't Kill Core Web Vitals

The Fine Line Between Delight and Lag

Interactive animations and scroll-driven experiences can transform a routine website into an unforgettable digital flagship. However, irresponsible animation code quickly introduces frame drops, layout thrashing, and devastating Interaction to Next Paint (INP) penalties.

By adhering to browser rendering pipeline constraints, you can harness GreenSock (GSAP) and ScrollTrigger to create fluid 60fps animations without sacrificing performance.

1. Animate Compositor Properties Exclusively

Browsers execute animations across three rendering phases: Layout, Paint, and Composite. Animating properties that trigger Layout (e.g., width, height, top, margin) forces the CPU to recalculate the entire page geometry on every frame.

The Golden Rule: Restrict continuous animations to GPU-composited properties:

  • transform: translate3d(), scale(), rotate()
  • opacity
// High performance GPU transform
gsap.to(".animated-card", {
  x: 100,
  scale: 1.05,
  opacity: 1,
  duration: 0.6,
  ease: "power2.out"
});

2. Taming ScrollTrigger

ScrollTrigger is powerful, but binding expensive recalculations to raw scroll events can freeze the main thread:

  • Batch Scroll Triggers: Use ScrollTrigger.batch() when animating collections of cards or grid items to minimize listener overhead.
  • Scrub Conservatively: When using numerical scrub smoothing (scrub: 1), avoid attaching complex SVG path morphing or multiple filter blurs simultaneously.
  • Always Clean Up: In Single Page Applications (React, Next.js, Astro), always kill ScrollTrigger instances when components unmount to prevent severe memory leaks:
    useEffect(() => {
      const ctx = gsap.context(() => { ... });
      return () => ctx.revert();
    }, []);
    

3. Honor User Motion Preferences

Always incorporate prefers-reduced-motion checks to disable or simplify heavy motion for users prone to vestibular motion sickness:

const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (!prefersReducedMotion) {
  // Execute cinematic timelines
}

Build Extraordinary Digital Experiences

Great animations look organic because they respect technical constraints. View interactive animation examples in my featured projects or consult on an upcoming build.