Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var xhr = new XMLHttpRequest();
xhr.open('GET', imageUrl);
xhr.responseType = 'blob';
xhr.onload = function() {
var img = document.createElement('img');
img.setAttribute('data-src', imageUrl);
img.setAttribute('id', s_id);
img.className = 'icon';
var objURL = this._createObjectURL(xhr.response);
img.setAttribute('src', objURL);
element.appendChild(img);
return img;
}.bind(this);
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment