Last active
April 3, 2016 11:03
-
-
Save englishextra/5b838277a698c36502309d19c4839eed 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
/*! | |
* load JS with requestAnimationFrame | |
* stackoverflow.com/questions/28394097/async-loading-css-stylesheet-using-requestanimationframe | |
*/ | |
function loadJSwithRaf(s, c) { | |
function l() { | |
var a = document.getElementsByTagName("script")[0], | |
t = document.createElement("script"); | |
t.src = s; | |
t.async = !0; | |
t.charset = "utf-8"; | |
a.parentNode.insertBefore(t, a); | |
c && "function" === typeof c && (t.onload = c); | |
return t; | |
} | |
"function" === typeof requestAnimationFrame ? requestAnimationFrame(l) : "function" === typeof mozRequestAnimationFrame ? mozRequestAnimationFrame(l) : "function" === typeof webkitRequestAnimationFrame ? webkitRequestAnimationFrame(l) : "function" === typeof msRequestAnimationFrame ? msRequestAnimationFrame(l) : "function" === typeof window.addEventListener ? window.addEventListener("load", l) : window.onload = l; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment