Skip to main content


Returns : Tween or Timeline

The tween or timeline associated with the given ID. Returns undefined if no tween or timeline has that ID.


When creating a tween or timeline you can assign it an id so that you can reference it later. This is helpful when using frameworks and build tools like React where keeping track of variables can be difficult., { id: "myTween", duration: 1, x: 100 });

let tween = gsap.getById("myTween"); //returns the tween

Important: GSAP automatically releases animations for garbage collection shortly after they complete, so getById() will only find animations that are active or haven't begun yet. Otherwise, if kept all animations around just in case you're gonna call getById() to find one, it could quickly clog up the system and lead to memory leaks. If you need to maintain a reference to an animation even after it completes, you should use a variable like this:

let myTween =, { duration: 1, x: 100 });

// later