views:

60

answers:

3

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  A: 

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

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

Starx
Nice. It even has callbacks!
Daniel Ribeiro
+1  A: 

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';
Delan Azabani
I've never seen this syntax. Where is it valid? If it's YUI that would be why I don't recognize it.
Nathan Taylor
It's just native JavaScript. No libraries needed. It instantiates a new `Image` object then sets its `src` to the image to preload. Then the image is preloaded.
Delan Azabani
It's what Yui uses for IE version: http://www.phpied.com/preload-cssjavascript-without-execution/
Daniel Ribeiro
+1  A: 

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.

karim79
Seems simple and nice, but threw me off with "You can workaround this with" and lack of callbacks. Sure I can manually use onLoad, but it kinda defeats the benefits of using a library.
Daniel Ribeiro
Also, if this (http://www.appelsiini.net/projects/lazyload/enabled.html) is the demo, it somehow doesn't work on linux (firefox 3.6, chorme 5, and opera 10.6)
Daniel Ribeiro
Tried it on Ubuntu 10.10 with Fireofx 3.6.8, *doesn't work*. Seems to have something Windows only? I'll investigate...
Delan Azabani