• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 18.  JavaScript Essentials > Loading Images into Cache

Loading Images into Cache

You can use JavaScript to load all of the images into your browser's cache as the page is initially displayed on the screen. One benefit is that rollovers (see page 306) are instantaneous.

To load images into cache:

1.
In the HEAD section of your document, type <SCRIPT LANGUAGE="javascript">.

2.
On the next line type <!-- to hide the script from older browsers.

3.
On the next line, type label=, where label is a word that identifies the image.

4.
Type new Image(h,w), where h and w are the image's height and width, in pixels.

5.
On the next line, type label, where label matches the label used in step 3.

6.
Directly following the name in step 5 (i.e. with no extra spaces), type .src="image.url", where image.url is the location of the image on the server.

7.
Repeat steps 3—6 for each image you wish to load into cache.

8.
Type // --> to end hiding the script. (That's two forward slashes, a space, two hyphens, and a greater-than symbol!)

9.
Type </SCRIPT> to complete the script.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint