Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Using Javascript to Pre-load Images


Guest

Recommended Posts

I tought this was a cool tip. So i wanted to share it with you guys.

 

Pre-loading uses a feature of browser technology known as the cache. The cache is the part of your computer where the web page gets stored when you download it. Ever noticed that when you return to a web page it loads in far quicker than the first time? That's because the files are still stored in your machine's cache and don't have to be downloaded again. If you use Internet Explorer you can view your cache files in the 'Temporary Internet Files' folder on your main drive.

 

The idea of Using Javascript to Pre-load Images is to load them in to the cache before they're even needed. This means that when they are called for they'll appear almost immediately.

 

Here's the script to load in the images. It uses a little simple javascript.

 

This should go in your Catalog/catalog/default.php

 

<SCRIPT LANGUAGE="JavaScript">

<!-- hide from non JavaScript Browsers

 

Image1= new Image(50,60)

Image1.src = "ben1.gif"

 

Image2 = new Image(70,80)

Image2.src = "ben2.gif"

 

Image3 = new Image(90,100)

Image3.src = "ben3.gif"

 

// End Hiding -->

</SCRIPT>

 

NOTE: Where it says **ben1.gif or ben2.gif or ben3.gif * should be replaced with the name of the images on your sites.

 

You can also add as many images as you want. Just follow the same structure.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...