Jump to content


How to tell when tweenlite and css plugin is loaded and ready to use?

Go to solution Solved by Rodrigo,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I'm working on a double click banner ad.  After an inital 40k polite load I'm going to be loading TweenLite.min.js and CSSPlugin.min.js, by adding it to the head. 


Is there an easy way to test when these two files are loaded and ready to go so I can start my animation? 



Link to comment
Share on other sites

  • Solution



Is fairly simple and straight forward, just check the global namespace in order to see if the TweenLite and CSSPlugin methods exists (remember we're talking about objects so you should check them as properties of the window object), like this:

if(window.TweenLite && window.CSSPlugin){
  //start your banner animation
  //perhaps start a setInterval to check for the assets to be loaded

Also you could try using an asset loader that has a callback to start the animations. There are several options that weight less than 3KB minified and using GZIP in the .HTACCESS file, I'm pretty sure your client won't have much objection with that.



  • Like 3
Link to comment
Share on other sites



In addition (actually I should've remembered this when I wrote the first post), you can check if GSAP is already added in the page and, if it is, also check the version in order to load the version you need or not. Please check this thread:



  • 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.