JSFiddle - React, Tailwind, and code Playground
CSS
body {
white-space: pre;
}
JavaScript
function loadImage(src) {
var image = new Image;
image.onload = function() {
if ('naturalHeight' in this) {
if (this.naturalHeight + this.naturalWidth === 0) {
this.onerror();
return;
}
} else if (this.width + this.height == 0) {
this.onerror();
return;
}
document.body.appendChild(image);
};
image.onerror = function() {
document.body.appendChild(document.createTextNode('\nError loading as image: ' + this.src));
//display error
};
image.src = src;
}
loadImage('/favicon.ico');
loadImage('/favicon.ico');
loadImage('/err');
loadImage('/moo.ico');
loadImage('http://www.example.com/');
loadImage('http://www.example.com/');