DEV Community

Arhan Khan
Arhan Khan

Posted on

GSAP for Beginners: Buttery Web Animations With a Few Lines of Code

GSAP, the GreenSock Animation Platform, is a JavaScript animation library that has powered the web's best motion design for over a decade. If CSS transitions feel limiting and you want timelines, easing, scroll-triggered animation, and precise control over every element, GSAP is the tool most professionals reach for. It works with plain JavaScript, React, Vue, or anything else.

What makes GSAP different is its timeline model. You chain animations into a timeline, control them with play, pause, and reverse, and scrub them with scroll position. The easing functions feel natural because they are built on real physics curves, not guesswork.

npm install gsap
Enter fullscreen mode Exit fullscreen mode

A first animation shows how little code it takes:

import gsap from 'gsap'

gsap.to('.card', {
  y: 0,
  opacity: 1,
  duration: 0.8,
  ease: 'power3.out',
  stagger: 0.1,
})
Enter fullscreen mode Exit fullscreen mode

A scroll-triggered reveal is just as short:

import { ScrollTrigger } from 'gsap/ScrollTrigger'

gsap.registerPlugin(ScrollTrigger)

gsap.from('.section', {
  y: 50,
  opacity: 0,
  scrollTrigger: { trigger: '.section', start: 'top 80%' },
})
Enter fullscreen mode Exit fullscreen mode

GSAP is a great fit for landing pages, portfolios, product showcases, and any site where motion is part of the design. Its ScrollTrigger plugin handles scroll animations without a scroll listener, and its timelines keep complex sequences readable.

The limits are honest ones. GSAP is a JavaScript dependency, so it adds weight to pages that might not need it. Over-animating hurts usability, and accessibility — reduced-motion preferences — is your responsibility. But for purposeful animation, that trade is usually worth it.

Try it once: animate one hero section with a timeline, then add a scroll trigger to the next section. The moment the page starts to feel alive is the whole point of GSAP.

Top comments (0)