Scevola Scevola - 1 year ago 146
Javascript Question

jquery preload images only if no cache

Nowadays it is very common that people add a preloader to images. It helps in rendering the website even if all images are not loaded.
My problem here is, when preloader is called, it doesn't check for any cached image. it always load the images from the server.
Do you have any idea to check for chached image before calling image preloader?
my preloader function is right below.


it loads all the images inside the main div.

Answer Source

You want to know if a image is loaded right?

$('#image').onload(function(){alert('Fires when image is loaded');});


if(document.getElementById('image').complete){alert('Image is loaded');}

Thats how you can check if a image is loaded or not.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download