You need to install the onload handler before you set the .src value.
In some versions of IE, if the image is in the browserβs cache, a download event will be fired immediately after setting the .src value. If your load handler is not already installed, you will skip this event.
In addition, naturalWidth and naturalHeight NOT supported in older versions of IE, so they will always be undefined. And you must use onerror and onabort to catch the error conditions.
No need to use jQuery for this. You can simply do this:
var img = new Image(), img.onload = function() { alert("loaded successfully"); } img.onerror = img.onabort = function() { alert("broken image"); }
source share