Jump to content
GreenSock

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×