Check if the complete
attribute of the Image
object is true
:
function is_cached(src) {
var image = new Image();
image.src = src;
return image.complete;
}
It seems to work (although it'll load the image if it isn't in the cache, which might not be what you want):
> is_cached('http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=3')
false
> is_cached('http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=3')
true