public
Last active

Lazy load images or delay them. Put this in the middle or end of <body> for 99.9% efficiency.

  • Download Gist
imgs-delayed-lazyload.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(function(){
var imgs = document.getElementsByTagName('img');
var l = imgs.length;
if (l<=0) return;
var srcs = [];
for (var i=0; i<l; i++){
var img = imgs[i];
srcs.push(img.src);
imgs[i].removeAttribute('src');
}
setTimeout(function(){
for (var i=0; i<l; i++){
imgs[i].src = srcs[i];
}
}, 5000);
})();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.