JSFiddle - React, Tailwind, and code Playground

JavaScript

var img1 = new Image();

img1.onerror = function() {
    console.log('img1 fail');
};

img1.onload = function() {
    console.log('img1 success');
};

img1.src = 'http://gvgmaps.com/linktothepast/maps/LegendOfZelda-ALinkToThePast-LightWorld.jpg';

var img2 = document.createElement('img');

img2.onerror = function() {
    console.log('img2 fail');
};

img2.onload = function() {
    console.log('img2 success');
};

img2.src = 'http://placehold.it/350x150';