Created
February 12, 2010 17:09
-
-
Save stedman/302758 to your computer and use it in GitHub Desktop.
Load the print stylesheet after DOM loads (to avoid flash of unstyled content—FOUC).
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
// ref: http://stevesouders.com/tests/dhtml-stylesheet-settimeout.php | |
// load print stylesheet after DOM loads | |
function loadStylesheet() { | |
var link = document.createElement('link'); | |
link.rel = 'stylesheet'; | |
link.type = 'text/css'; | |
link.media = 'print'; | |
link.href = '/css/print.css'; | |
document.getElementsByTagName('head')[0].appendChild(link); | |
} | |
// use1: jQuery(window).load(function(){loadStylesheet();}) | |
// use2: setTimeout(loadStylesheet, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment