Created
March 12, 2010 04:25
-
-
Save cheeaun/330029 to your computer and use it in GitHub Desktop.
Lazy load images or delay them. Put this in the middle or end of <body> for 99.9% efficiency.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment