I saw in the documentation that it does not matter how many times you import and register GSAP plugins; I'm doing it for all of my components where I use it. It gets loaded up to 12 times on one page (12 child components in the page, each using GSAP). Does it matter how many times you set GSAP defaults within each child component? Settings defaults in one seems to impact the other components.
Setting a default duration changed the duration of all tweens (it made them slower) acros
Nope, gsap.defaults() is global, so you should probably only call that one time.
I would recommend this pattern to anyone who uses modules. Do all your plugin registration and GSAP configuration in a single file like so.
import { gsap } from "gsap";
import { Draggable } from "gsap/Draggable";
import { TextPlugin } from "gsap/TextPlugin";
gsap.registerPlugin(Draggable, TextPlugin);
gsap.defaults({
duration: 2
});
export * from "gsap";
export * from "gsap/Draggable";