Created
October 8, 2015 10:53
-
-
Save lastguest/76eb6e307ea7d3fbe37c to your computer and use it in GitHub Desktop.
[JavaScript] asyncLoadCSS
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
function asyncLoadCSS (css_href) { | |
var css_link = function () { | |
var h = document.getElementsByTagName('head')[0] | |
var l = document.createElement('link') | |
l.rel = 'stylesheet' | |
l.href = css_href | |
h.parentNode.insertBefore(l, h) | |
}, RAF = requestAnimationFrame || mozRequestAnimationFrame | |
|| webkitRequestAnimationFrame || msRequestAnimationFrame | |
if (RAF) RAF(css_link); else window.addEventListener('load', css_link) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment