Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created June 5, 2014 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuc-arc-f/121662900eeb08c14bc2 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/121662900eeb08c14bc2 to your computer and use it in GitHub Desktop.
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