Image-Preload?

They have: 10 posts

Joined: Mar 2000

Okay. Is an image-pre-load script good if users view my site and they don't want to wait long again for images to load? If it is good to use them, what is the script?

Jesse

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

You preload images by listing them in an array, or listing them in the body tag. I prefer the array method, then call to the images from the array, but that's just me. Someone else will know the onLoad part.

Basically, if you are using the images for rollovers, preload them -- no one will wait around in real life to see the effect of your rollover if they have to hover for it to load (as in when they aren't preloaded).

Don't use it, though, to load full size images for thumbnails -- it removes the choice from the user. They should be able to decide whether they want to load the larger image or not.

Suzanne

------------------
Zero Cattle
Suzanne
Tables DeMystified

They have: 231 posts

Joined: Feb 2000

I would only bother preloading images to be used in rollovers. Always preload rollover images because there is nothing more annoying than rollovers that download onMouseOver.

Here is the code for pre-loading:

if (document.images) {
IMG_NAME1 = new Image();
IMG_NAME1.src = "images/file1.gif";
IMG_NAME2 = new Image();
IMG_NAME2.src = "images/file2.gif";
}

Make sure you include the if statement so that older browsers dont generate errors.

:: Lloyd Hassell :: http://www14.brinkster.com/lloydh ::

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.