Last active
April 10, 2017 08:46
-
-
Save danwarfel/d8ed1a7f06f8dd393b79 to your computer and use it in GitHub Desktop.
Defer Loading of External CSS Until Page Loaded
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
var cb = function() { | |
var l = document.createElement('link'); l.rel = 'stylesheet'; | |
l.href = '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css'; | |
var h = document.getElementsByTagName('head')[0]; h.insertBefore(l, h.lastChild); | |
}; | |
var raf = requestAnimationFrame || mozRequestAnimationFrame || | |
webkitRequestAnimationFrame || msRequestAnimationFrame; | |
if (raf) raf(cb); | |
else if (window.addEventListener) window.addEventListener('load', cb); | |
else if (window.attachEvent) window.attachEvent("onload", cb); | |
else window.onload = cb; | |
// from http://codesr.thewebflash.com/2014/08/defer-loading-external-css-until-page.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment