Skip to content

Instantly share code, notes, and snippets.

@Billcountry
Last active February 4, 2018 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Billcountry/1a17d28853fe6fb600299747a7de64c5 to your computer and use it in GitHub Desktop.
Save Billcountry/1a17d28853fe6fb600299747a7de64c5 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