Jump to content


Does window.GreenSockGlobals work with 3.x?

Recommended Posts



In 2.x you could set window.GreenSockGlobals = {}; and GreenSock would put all it's variables into that object, avoiding the global window namespace.


In 3.1.1 the same thing doesn't seem to have any effect, as all the variables are in the global namespace window.gsap, window.gsapVersions, etc.


Any way to force 3.x to stick to just 1 global var? I like to keep the global namespace as unpolluted as possible.



Link to comment
Share on other sites

GreenSockGlobals is still there, but I think it will still install everything as a global. It's more for using different versions of gsap on the same site. 


To get rid of all the globals, you can use modules and everything will be scoped to the module. 


See the Pen fac322113bc12c54959ea2cda1287b0f by osublake (@osublake) on CodePen





  • Like 2
Link to comment
Share on other sites

Yep, @OSUblake is correct. Just use the modules. 


For the record, @OSUblake, internally GSAP 3 does indeed honor the GreenSockGlobals object just like in v2.x but when Rollup creates the ES5 UMD files it assigns all the exports to the window! So it's the bundler doing that, not GSAP. I'm not sure there's a super clean solution for that, quite frankly.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.