Skip to content

Instantly share code, notes, and snippets.

@harrisrobin
Created August 28, 2014 20:00
Show Gist options
  • Save harrisrobin/64c60119457d891ea6d5 to your computer and use it in GitHub Desktop.
Save harrisrobin/64c60119457d891ea6d5 to your computer and use it in GitHub Desktop.
// Usage:
// 1. Extract critical path CSS (see: http://addyosmani.com/blog/tag/critical-path-css)
// 2. Inline extracted styles within <head>
// 2. Place loader IIFE within <script> tags at end of <body>
(function(b,f){var c=[
"styles/style1.css",
"styles/style2.css"
],a=function(){for(var g=0;g<c.length;g++){var d=f.createElement("link");d.rel="stylesheet";
d.href=c[g];var j=f.getElementsByTagName("head")[0];j.parentNode.insertBefore(d,j)}},
e=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||
b.msRequestAnimationFrame;if(e){e(a)}else{window.addEventListener("load",a)}})(window,document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment