1

I want to store image in cache memory to speed up my website. So, how to store image in cache memory in Javascript or jQuery for website's speed optimization?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
badal
  • 73
  • 1
  • 9
  • 1
    The browser does this for you the first time the image is loaded. You can force it to happen sooner by loading the image sooner via code. – Kevin B Mar 20 '13 at 17:36
  • Looks like this question has been asked before: http://stackoverflow.com/questions/476679/preloading-images-with-jquery – yagooar Mar 20 '13 at 17:51

3 Answers3

4

You can force the 'loading' into cache of these images upfront by using HTML hidden img tags on the initial load. Later HTTP requests for the same images should return from cache.

By default, most browsers do the caching for you, provided you do not provide other instructions in the HTTP response headers for those image resources.

chinnychinchin
  • 5,564
  • 2
  • 21
  • 18
1

try this

$('#gallery img').each(function(i){
    if(this.complete){
        doSomething();
    } else {
        $(this).load(function(){
            doSomethingElse();
        });
    }
});
-2

Google will help you!

Take a look http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

Vasant
  • 968
  • 1
  • 6
  • 5
  • 1
    The question is about javascript but the accepted answer is related to android? – boz Mar 22 '13 at 10:14