Forked from disinfeqt/twitter_offscreen_preload.html
Created
August 19, 2011 05:03
-
-
Save chrisyip/1156086 to your computer and use it in GitHub Desktop.
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
window.onload = function(){ | |
var doc = document | |
, img = doc.createElement('img') | |
, div = doc.createElement('div') | |
, body = doc.getElementsByTagName('body')[0]; | |
img.className = 'preload'; | |
img.style.cssText = ';position:absolute;top:-999em;left:-999em;width:0;height:0;visibility:hidden;'; | |
// ajax loaded or predefined img list | |
var arr = imgList | |
, str | |
, tmp; | |
div.id = 'preload-wrapper'; | |
while(src = arr.pop()){ | |
tmp = img.cloneNode(!1); | |
tmp.src = src; | |
div.appendChild(tmp); | |
} | |
body.appendChild(div); | |
// remove div when all loaded | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment