JSFiddle - React, Tailwind, and code Playground
HTML
<img src="http://www.gravatar.com/avatar/e96a421d76c1fc107a5d291c6999b2ef?s=32&d=identicon&r=PG" alt="Example" />
JavaScript
var loaded = function() {
document.body.appendChild(document.createTextNode('New resource loaded!'));
};
(function() {
var HTMLImageElementSetAttribute = HTMLImageElement.prototype.setAttribute;
HTMLImageElement.prototype.setAttribute = function(attribute, value) {
var image;
if (attribute == 'src') {
image = new Image;
image.addEventListener('load', loaded, false);
image.src = value;
}
return HTMLImageElementSetAttribute.apply(this, arguments);
}
})();
document.images[0].setAttribute('src', 'http://www.gravatar.com/avatar/7d5ce1d82649f94df582b84950342d60?s=32&d=identicon&r=PG&random=' + +new Date);