Is it possible to detect when all images are loaded via a jQuery event?
Ideally, there should be a
$(document).idle(function()
{
}
If you want to check for not all images, but a specific one (eg. an image that you replaced dynamically after DOM is already complete) you can use this:
$('#myImage').attr('src', 'image.jpg').on("load", function() {
alert('Image Loaded');
});
Use of the jQuery $().load() as an IMG event handler isn't guaranteed. If the image loads from the cache, some browsers may not fire off the event. In the case of (older?) versions of Safari, if you changed the SRC property of an IMG element to the same value, the onload event will NOT fire.
It appears that this is recognized in the latest jQuery (1.4.x) - http://api.jquery.com/load-event - to quote:
It is possible that the load event will not be triggered if the image is loaded from the browser cache. To account for this possibility, we can use a special load event that fires immediately if the image is ready. event.special.load is currently available as a plugin.
There is a plug-in now to recognize this case and IE's "complete" property for IMG element load states: http://github.com/peol/jquery.imgloaded/raw/master/ahpi.imgload.js