Created
July 3, 2011 20:41
-
-
Save ded/1062585 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
test_script_elem = document.createElement("script"), | |
explicit_preloading = typeof test_script_elem.preload == "boolean", | |
real_preloading = explicit_preloading || (test_script_elem.readyState && test_script_elem.readyState == "uninitialized"), | |
script = document.createElement('script') | |
if (real_preloading) { | |
registry_item.elem = script; | |
if (explicit_preloading) { | |
script.preload = true; | |
script.onpreload = onload; | |
} | |
else { | |
script.onreadystatechange = function(){ | |
if (script.readyState == "loaded") onload(); | |
script.onreadystatechange = null; | |
}; | |
} | |
script.src = src; // now preloaded. appending will execute it | |
} | |
else { | |
script.type = "text/cache-script"; | |
create_script_load_listener(script,registry_item,"ready", function() { | |
// doesn't get here | |
append_to.removeChild(script); | |
onload(); | |
}) | |
script.src = src; | |
append_to.insertBefore(script,append_to.firstChild); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment