JSFiddle - React, Tailwind, and code Playground
HTML
<img id="myImg" src=""/>
JavaScript
function ajaxImage(url, elm){
var xhr = new XMLHttpRequest(),
blob, objectURL, arrayBufferView;
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.addEventListener('load', function () {
if (xhr.status === 200) {
arrayBufferView = new Uint8Array(xhr.response),
blob = new Blob([arrayBufferView], {'type': 'image\/jpeg'}),
objectURL = window.URL.createObjectURL(blob);
elm.src = objectURL;
}
}, false);
xhr.send();
}
window.addEventListener('load', function () {
ajaxImage('/img/logo.png', document.getElementById('myImg'));
}, false);