Pre-Load Images
- Home
- Javascript
- Pre-Load Images
Why Pre-Load Anything?
Speed, man, speed! Fast, fast, fast!
Have you ever noticed that pages you've visited in the past always load faster than a page you're visiting for the first time? It seems like you only have to go through all of that item by item downloading once and from that point on, you're good to go.
Well, the reason that page, and all those images, came so fast the second time was that they had been "cached" (pronounced cashed).
<script language="JavaScript">
<!--
arImageSrc = new Array (
"image.gif",
"image2.gif",
"image3.jpg",
"image4.jpg"
)
arImageList = new Array ();
for (counter in arImageSrc) {
arImageList[counter] = new Image();
arImageList[counter].src =
arImageSrc[counter];
}
// -->
</script>
put the above script into your <head> tag
pre-load images javascript speed