Gaya / queryloader2

Version of the QueryLoader by Gaya Kessler. Preload images with ease.
http://blog.gaya.ninja/articles/queryloader2-preload-your-images-with-ease/
MIT License
718 stars 232 forks source link

Slow loading if no images found. #150

Open lcdsantos opened 8 years ago

lcdsantos commented 8 years ago

When the page has no images, the plugin wait for the maxTime to complete, instead of just completing right away.

Example: http://jsbin.com/dureti/edit?html,output - Contains 1 image, loads pretty fast. http://jsbin.com/henaba/edit?html,output - Has no images, takes really long time to complete.

What if we add a check after getImageSrcs function on https://github.com/Gaya/queryloader2/blob/183e0c0ae129300982c8e68e5eaba1f0c87c0d41/src/ImagePreloader/index.js#L29

if (this.sources.length === 0) {
  this.done === true;
  this.updateProgress();
}
Gaya commented 8 years ago

Sounds like a good plan! You can add a pull request if you'd like to fix this problem.