Navigation Menu
Alphabetical Listing
Site Contents

Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner














Internet.com

IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Developer Channel

FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

This script will preload images to enable your pages to load faster. Place the images in one directory and make sure they have all the same extension (defaults to "jpg").


See the demo here

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: imagePreloader.js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

2. From: Jayson
Not sure I understand?
10/24/2007 05:11:51

I love the idea but have a few questions...

---------------------------------
The section where you have:
"addLoadEvent(function() {
preload('img1','img2','img3','img4','img5','img6','img7','img8','img9','img10','img11','img12');
});"

Are these the names of your images?
Like: "<img src="images/img1.jpg" border="0">"
---------------------------------
Also this:
"var dir = 'images/' // path to images"
What is the correct syntax here for the path?
With or wihout the opening and closing tags, "/"?
---------------------------------
Cheers

3. From: Lee (Admin)
10/26/2007 13:50:15

Yes, in the section:
preload('img1','img2','img3', ...
these are the names of your images. (Names only, no path.)

Yes, in this section:
"var dir = 'images/' // path to images"

this is the actual path, including the ending "/", to your images.

4. From: Jayson
PHP?
09/10/2008 04:30:28

How cool would it be to be able to dynamically add images based on PHP, ASP or CFusion from a Database?

Will there be a future release for these ideas?

Cheers

5. From: Lee (Admin)
10/31/2008 15:23:10

You would need to contact the author on that one.

1. From: martin
05/13/2007 11:40:33

where do you put in the javascript file where the images file path is ?


Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.