Created
May 25, 2014 01:06
-
-
Save curiositry/90e377d1b91c402ce536 to your computer and use it in GitHub Desktop.
Defer loading CSS via google PageSpeed
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
| <html> | |
| <head> | |
| <style> | |
| .blue{color:blue;} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="blue"> | |
| Hello, world! | |
| </div> | |
| <script> | |
| var cb = function() { | |
| var l = document.createElement('link'); l.rel = 'stylesheet'; | |
| l.href = 'small.css'; | |
| var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h); | |
| }; | |
| var raf = requestAnimationFrame || mozRequestAnimationFrame || | |
| webkitRequestAnimationFrame || msRequestAnimationFrame; | |
| if (raf) raf(cb); | |
| else window.addEventListener('load', cb); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment