Skip to content

Instantly share code, notes, and snippets.

@musebe
Forked from Billcountry/images.js
Created February 4, 2018 11:34
Show Gist options
  • Save musebe/7b728ae41b1851f9f1bf655bcbb2dc1c to your computer and use it in GitHub Desktop.
Save musebe/7b728ae41b1851f9f1bf655bcbb2dc1c to your computer and use it in GitHub Desktop.
Load images after the whole page has loaded by just adding the class .async-img
// Default image data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mO8dPv2fwAImAOJMh4kwgAAAABJRU5ErkJggg==
function load_images(){
var images = document.querySelectorAll(".async-img");
for(var id=0; id<images.length; id++){
var image = images[id];
var img_url = image.getAttribute('url');
image.src = img_url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment