Tech Support Forum banner
Status
Not open for further replies.
1 - 10 of 10 Posts

·
Registered
Joined
·
1,153 Posts
Discussion Starter · #1 ·
Hi People :wave:

How do I cache images so the browser does not have to reload them every time they are referenced? I do this in a loop selecting images at random.

Thanks

Brent
 

·
God (TSF Enthusiast)
Joined
·
1,118 Posts
Code:
   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];
            }
         }
      }
   }
This help any?
 

·
Registered
Joined
·
409 Posts
ahmorrow's script will preload the images, the browser should cache any images loaded automatically, unless the user has set it otherwise.

I don't really understand your question, is that what you were looking for? A preloading sort of thing?
 

·
God (TSF Enthusiast)
Joined
·
1,118 Posts
That's what I assumed... I mean, anything else is based on the viewer of the site, not so much the programmer.
 

·
Registered
Joined
·
1,153 Posts
Discussion Starter · #5 ·
OK...I am hosting on my computer. When I call up my page from another computer I see that it is continually loading and reloading the images.

I do however load the images with JavaScript into an array at startup. This should suffice...no?

To regress a bit, how does one tweek the browser to cache images? I think that could be the problem.
 

·
Registered
Joined
·
1,153 Posts
Discussion Starter · #6 ·
OK...I am hosting on my computer. When I call up my page from another computer I see that it is continually loading and reloading the images.

I do however load the images with JavaScript into an array at startup. This should suffice...no?

To regress a bit, how does one tweek the browser to cache images? I think that could be the problem.
 

·
God (TSF Enthusiast)
Joined
·
1,118 Posts
For IE 5+
Tools--Internet Options-->General[tab]-->Temporary Internet Files[category]-->Settings-->Change 'Amount of disk space to use...' to the desired amount by dragging the slider.

For FireFox
Edit-->Preferences-->Advanced-->Network[tab]-->Offline Storage[category]-->If you can't find it from here, you're stupid.

Not sure about Safari and that covers the most popular.
 

·
God (TSF Enthusiast)
Joined
·
1,118 Posts
That should be plenty. If not, try increasing it to 100 or 200. Just be sure to delete your cache every once in a while and defrag once a week. No matter what it will take a moment for the pic to load, especially on older PCs or ones with little/damaged RAM
 
1 - 10 of 10 Posts
Status
Not open for further replies.
Top