Jump to content
Search Community

GSAP encountered missing dependency: com.greensock.preloadImages

Ben Stanley test
Moderator Tag

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

Hi,

 

I wrote a custom Javascript function to preload images on my site (completely unrelated to GSAP). I used the Object prototype method.

Object.prototype.preloadImages = function(callback) {
    /* ... */
};

This is how it looks. The code inside is just plain JS.

 

But whenever I add it to my project, GSAP throws an error: GSAP encountered missing dependency: com.greensock.preloadImages.

 

Then it logs: Uncaught TypeError: o.parse is not a function (logs this error over and over)

 

Seems like GSAP is seeing the new function and trying to do something related to it.

 

Any suggestions on how to fix it?

 

I could just switch it from Object.prototype to a regular function; but I prefer having it this way. It's a re-usable plugin that I include in lots of projects, so I don't really want to change it just for this.

Link to comment
Share on other sites

Ah yes, that's a big no-no. Messing with native prototypes is really dangerous. The way you were doing it was causing every single JavaScript object to have a new enumerable property which can throw off for...in loops. Literally for every single object. Glad you moved away from that and found a different solution that works :)

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.
×
×
  • Create New...