Recommended Javascript Image preloader [closed]

2019-06-14 02:01发布

问题:

There are a couple of tools and several tutorials (even some including links to github) on how to preloading images and other artifacts, like css and scripts. YUI3 preloader seems to be the most reliable one.

Is there a better one? Are there any others that are faster (possibly through parallel loading), more usable or has better browser compatibility? Maybe one that uses jquery instead of YUI...

回答1:

I like the jquery preload plugin. Try this.........

http://plugins.jquery.com/project/Preload



回答2:

As a suggestion, you can use a lazy loader such as this one to only load images once they are have been scrolled and are in the viewport.



回答3:

This one is the best.

(new Image).src = '/path/to/image/to/preload';

To preload other things (thanks Daniel) you can try this:

document.createElement('object').data = '/path/to/resource/to/preload';