Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Namespace GSAP build

Recommended Posts

Hi there,


I was wondering if there is a way to namespace "gsap" instance to avoid conflicts with other libraries that import gsap explicitly.


Main reason behind this is because I develop WordPress themes, and so other plugins may include gsap library in different versions as well, so what I wanted is a custom build only for my theme and not interfere with other possible instances of GSAP. How can this be done?


I know this may not be a good practice to include two or more versions of GSAP on page but with Wordpress this issue needs to be resolved this way I guess.


Thank you

Share this post

Link to post
Share on other sites

Hey arl1nd. 


If you can use ES modules you can have two separate versions of GSAP running. See this thread for more info: 

However, given you're building themes I doubt that's an option or at least desirable :) 


I would instead approach this a different way: Advertise that your theme already loads GSAP! It's a plus, they don't have to load a second version of GSAP to animate things. It saves on load time, load size, and (more minorly) would perform slightly better. 


Another approach would be for your theme to wait to load GSAP until after the user's custom scripts have loaded. Check if GSAP already exists and use that if so, load it if not. 

  • Like 1

Share this post

Link to post
Share on other sites
10 minutes ago, OSUblake said:

If you're using script tags to load gsap, then you can do this.

Very interesting and effective approach :) 

Share this post

Link to post
Share on other sites

Thank you for helping with this. Really appreciate it!


The solution from @OSUblake seems to do the trick as a quick fix.


Share this post

Link to post
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.