GSAP Overview — Web Animation

GSAP 3.15.0 is a JavaScript animation library, free including every plugin (extra feature) since 3.13 (30 April 2025), under a "Standard no-charge license"…

A school show's running order usually reads like this: the MC opens at minute 0, the head teacher's speech starts as soon as the MC is done, and the music comes in a little before the speech ends. Each item has a start time calculated from another item, and the whole event can be paused or rewound. GSAP (GreenSock Animation Platform) lays out animations the same way. Its main strength is the timeline: you lay out many animations on one time line, like the items in a running order, and control them all with one remote.

GSAP is a JavaScript animation library that can animate any number: CSS properties, SVG attributes, even properties of a plain JavaScript object.

Version and licence

As of October 2026 the latest version is 3.15.0 (13 April 2026). Webflow bought GreenSock at the end of 2024. Since GSAP 3.13 (30 April 2025), all of GSAP is free, for commercial projects too. That includes the plugins (extra features) that used to be paid (SplitText, MorphSVG) and ScrollTrigger. Its licence (the rules for using it) is the "Standard no-charge license", not MIT (an open source licence with almost no conditions). This means you may not use GSAP inside a tool that competes with Webflow: a tool for building animations visually, without writing code.

npm install gsap

Its size, measured from the 3.15.0 package: the core gsap.min.js is 72.9 KB (28.3 KB when compressed with gzip), the ScrollTrigger plugin 44.6 KB (18 KB gzipped). GSAP is not a dependency (a package in use) of BelajarWeb.dev. So the Lab runs a small home-made timeline that places animations by the same rules as GSAP, and says so plainly.

Tweens: to, from, fromTo

A single animation in GSAP is called a tween. In Motion, a tween is a kind of transition. In GSAP, a tween is one whole animation: a target, target values, a duration and an easing. There are three ways to make one:

import gsap from 'gsap';

gsap.to('.toast', { y: 0, autoAlpha: 1, duration: 0.2 });          // from the current state TO these values
gsap.from('.room', { y: 16, autoAlpha: 0, stagger: 0.06 });         // FROM these values to the current state
gsap.fromTo('.check path', { strokeDashoffset: 1 }, { strokeDashoffset: 0, duration: 0.3 });

The timeline and the position parameter

Take a guess first: these two lines are written one after the other, gsap.to('.toast', { x: 100, duration: 1 }) then gsap.to('.toast', { y: 50, duration: 1 }). Does the toast move right first and then down?

No. Every gsap.to() starts the moment it is called. So the two lines run together (in parallel), and the toast moves diagonally. They don't cancel each other because the properties differ, and GSAP's default is overwrite: false.

To run things in turn, use a timeline. In GSAP, a timeline is a container that places many tweens on one time line, not the scroll timeline from lesson 7. This is Mist Homestay's booking confirmation after the guest presses "Yes, book":

const tl = gsap.timeline({ paused: true });

tl.to('.modal', { autoAlpha: 0, scale: 0.96, duration: 0.15, ease: 'power1.in' })        // the dialog closes
  .fromTo('.toast', { autoAlpha: 0, y: 16 }, { autoAlpha: 1, y: 0, duration: 0.2 }, '-=0.05')
  .fromTo('.check path', { strokeDashoffset: 1 }, { strokeDashoffset: 0, duration: 0.3 }, '<0.1')
  .fromTo('.toast .bar', { scaleX: 1 }, { scaleX: 0, duration: 5, ease: 'none' }, '>');

document.querySelector('.yes').addEventListener('click', () => tl.restart());

This timeline is created paused (paused: true), and tl.restart() plays it from the start each time the "Yes, book" button (.yes) is clicked. The last argument on the next three lines ('-=0.05', '<0.1', '>') is the position parameter: when that tween starts. This table uses the schedule above. The dialog runs 0 to 150 ms, and the last column shows when the toast starts with each position:

Position Meaning Toast starts
(left out) at the end of the timeline 150 ms
'>' at the end of the previous tween 150 ms
'-=0.05' 0.05 seconds before the end of the timeline (an overlap) 100 ms
'+=0.2' 0.2 seconds after the end of the timeline (a gap) 350 ms
'<' together with the start of the previous tween 0 ms
'<0.1' 0.1 seconds after the start of the previous tween
2 exactly at second 2 of the timeline

With '-=0.05', we ran GSAP 3.15.0 and read its schedule: the dialog 0 to 150 ms, the toast 100 to 300, the check-mark 200 to 500 ('<0.1' from the toast's start), and the bar (a line in the toast that shrinks over 5 seconds) 500 to 5,500. If you switch the toast's position to '<', everything after it starts earlier too: the toast 0 to 200, the check-mark 100 to 400.

One remote for everything

Like a running order that can be paused or rewound, a timeline is controlled like a single animation: tl.pause(), tl.play(), tl.reverse(), tl.seek(0.3) (jump to second 0.3), tl.timeScale(2) (twice as fast), tl.restart(), tl.progress() (the progress, 0 to 1). Much like the WAAPI remote in lesson 8 (Web Animations API), but for the whole sequence.

ScrollTrigger, the most popular plugin, ties a tween or timeline to the scroll position:

gsap.registerPlugin(ScrollTrigger);
gsap.from('.room', { y: 16, autoAlpha: 0, stagger: 0.06, scrollTrigger: { trigger: '.rooms', start: 'top 80%' } });

In this example, the .room cards start to enter when the top edge of .rooms (the list of cards) reaches 80% of the screen height from the top. When GSAP is installed with npm, ScrollTrigger must be imported first: import { ScrollTrigger } from 'gsap/ScrollTrigger';. Without that line, gsap.registerPlugin(ScrollTrigger) throws ReferenceError: ScrollTrigger is not defined (tested with gsap 3.15.1 in Chromium 156).

For simple effects, scroll-driven animations (lesson 7) and IntersectionObserver (lesson 10) are enough without a library.

How it works: a ticker on the main thread

GSAP does not use CSS animations or WAAPI. It has one ticker, a beat that requestAnimationFrame runs on every frame. On every beat, the ticker computes each tween's values, then writes inline styles. So, just like rAF in lesson 6, GSAP stops when the main thread is busy. We measured it in Chromium 147, with the main thread blocked for 500 ms in the middle of a 1 second animation:

Animation Frames drawn while blocked
CSS transition on transform 60
WAAPI on transform 60
GSAP x 0

GSAP has lagSmoothing: when the gap between beats is over 500 ms, GSAP treats it as just 33 ms. So after the block, the animation carries on from where it stopped instead of jumping to where it should be. In our measurement, GSAP still ran 103 more frames after the block ended.

When GSAP wins, and when it doesn't

GSAP wins at timelines: long sequences with overlaps, precise playback control (pause, seek, reverse, timeScale), and consistent results across browsers. It can also animate things that are not CSS: SVG attributes, or numbers on a JavaScript object for a canvas or three.js (a 3D library).

What is not its strength: GSAP does not run on a separate thread (it runs on the main thread), it is not turned into CSS keyframes, and it does not make width or height cheap. Animating width still makes the browser compute layout on every frame.

You don't need GSAP for a button that shrinks when pressed or for fading one element. A 100 ms CSS transition is enough, without 28 KB of JavaScript. For animation that must stay smooth while the page is busy, CSS or WAAPI with transform and opacity is stronger.

⚠️ From the wrong order to doubled animations

TL;DR: GSAP 3.15.0 is a JavaScript animation library, free including every plugin (extra feature) since 3.13 (30 April 2025), under a "Standard no-charge license" that is not MIT. It animates any number through tweens (single animations), made with gsap.to, from or fromTo. Durations are in seconds, with a default of 0.5 seconds and the easing power1.out. Short names include x, y, rotation, scale and autoAlpha. Two gsap.to() calls in a row run together. Order comes from gsap.timeline() (a container of tweens on one time line) and the position parameter (when each tween starts). For example, '>' the end of the previous tween, '<' its start, '-=0.05' an overlap, '+=0.2' a gap, '<0.1' 0.1 seconds after the previous tween's start. One remote (pause, play, reverse, seek, timeScale) controls the whole sequence. GSAP writes styles from a ticker (a beat on every frame from requestAnimationFrame) on the main thread. With the main thread blocked for 500 ms, GSAP drew 0 frames (CSS and WAAPI 60 each). Then lagSmoothing (a gap over 500 ms counted as 33 ms) makes it continue instead of jumping. Use GSAP for complex sequences, SVG and non-CSS values. Use CSS or WAAPI for simple movement that must stay smooth.

⚡ Two lines, run together

Guess first: gsap.to() moves an element to target values. gsap.to('.toast', { x: 100, duration: 1 }) then gsap.to('.toast', { y: 50, duration: 1 }) are written one after the other. Does the toast move right first, then down?

No. Every gsap.to() starts the moment it is called, so the two lines run together and the toast moves diagonally.

Meaning: GSAP is a JavaScript animation library. A single animation in GSAP is called a tween, and its duration is in seconds: duration: 300 means 300 seconds.

⚡ The timeline and the position parameter

Write:

const tl = gsap.timeline({ paused: true });

tl.to('.modal', { autoAlpha: 0, scale: 0.96, duration: 0.15, ease: 'power1.in' })        // the dialog closes
  .fromTo('.toast', { autoAlpha: 0, y: 16 }, { autoAlpha: 1, y: 0, duration: 0.2 }, '-=0.05')
  .fromTo('.check path', { strokeDashoffset: 1 }, { strokeDashoffset: 0, duration: 0.3 }, '<0.1')
  .fromTo('.toast .bar', { scaleX: 1 }, { scaleX: 0, duration: 5, ease: 'none' }, '>');

Meaning: gsap.timeline() creates a timeline, a container that places tweens on one time line. The last arguments '-=0.05', '<0.1' and '>' (the position parameter) decide when each tween starts. '-=0.05' starts 0.05 seconds before the end of the timeline (an overlap), '<0.1' is 0.1 seconds after the start of the previous tween, '>' is at the end of the previous tween.

⚡ One remote for everything

Meaning: A timeline is controlled like a single animation, with one remote for the whole sequence: tl.pause(), tl.reverse(), tl.seek(0.3) (jump to second 0.3), tl.timeScale(2) (twice as fast). That is GSAP's strength: timelines, precise playback control, and consistent results across browsers.

⚡ A ticker on the main thread

Meaning: GSAP writes inline styles from a ticker, a beat that requestAnimationFrame runs on the main thread. With the main thread blocked for 500 ms, GSAP drew 0 frames, CSS and WAAPI 60 each. For simple movement that must stay smooth, use CSS or WAAPI.

What you will learn