Click to See Complete Forum and Search --> : MM_preloadImages() and cache


sander
08-11-2004, 02:25 AM
Hello,

I am working on a fairly large website and I am trying to bring the monthly bandwidth usage down because hosting is simply getting expensive.

I'm stepping through all the code to see if I can cut somewhere untill I found the (in)famous MM_preloadImages() from MacroMedia. I'm not that much of a JavaScipt guy (I usually stick to HTML and PHP) and I can't figure this function out. Here it is for sake of completeness:


function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[ i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[ i];}}
}


The description on the MM website says that it preloads images from the server to the cache so they can be quickly displayed with rollover effects. My worry is this: Does it download those images everytime this script executes (ever pageload) thus burning my bandwidth? Or does it just really download them to cache if they're not there yet (so it downloads only on the first page, not the subsequent pages that you click through).

Thanks in advance for your help!