Preloading images?

They have: 9 posts

Joined: Dec 1999

HI,
I've just read the tutorial on pre loading images with the use of a javascript in the <HEAD>. I was wondering does the same apply for background images (wallpaper). If so do I need to change the javascript.

Thanks in Advance

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

You could use the background image in the scritp like you would any other image, though I don't think you can change the background image (ie a rollover etc.) with a script. Preloading shouldn't be a problem though-- but it might not make much difference with a background image since it is only used in one spot.

They have: 9 posts

Joined: Dec 1999

Ok thats great. Thanks for the help.
The site is www.i-t-f.co.uk (gaming web site)
and sometimes the background takes a little bit to load, its not really a problem.
Thanks again for your reply.

Jaiem's picture

They have: 1,191 posts

Joined: Apr 1999

Pardon my ignorance:

What is the advantage(s) of preloading an image? It seems to me the time to load an image is the same whether it's loaded via the JavaScript preload function or loaded directly into a page. IOW, if I have a 30k image file, will it load faster as a preload than as a URL in the <img> tag?

------------------
ArtsNFlies.com
Original art, hand tied flies, unique books and gifts, free sweepstakes and MORE!
Come see what everyone is talking about!

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

It doesn't change the loading time of the image, but it starts loading the image before the rest of the page.

It is mainly used for rollovers, where you want the image to change right away rather than waiting on it to download when you mouseover.

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.