There are a lot of pre-load script examples available on stack overflow but is there a way to check if the browser already has the image preloaded in it’s cache and if it is then do not initiate/overtake the image pre-loading with the .load() function and just let the browser put in the image?
Share
I don’t think so, but more importantly if your browser already has the image, it won’t try to reload it anyways (it will just ask the server for the headers and see that the image hasn’t changed).
If you want, you can put ‘far futures expires’ headers on the images, so the browser doesn’t even try to check the server and just assumes any images it has in its cache are okay. This would effectively do what you asked.
I think Yahoo says it better than I can:
So basically, you can put the header
Expires: Thu, 31 Dec 2030 0:00:00 GMTand the browser won’t go looking for the image again for another 29 years or so : ). Of course this means if you change the images, you’ll have to rename them.