Skip to content

Instantly share code, notes, and snippets.

View harrisrobin's full-sized avatar
🛳️
Shipping

harris.dev harrisrobin

🛳️
Shipping
View GitHub Profile
@harrisrobin
harrisrobin / recursion.js
Created November 3, 2015 19:28 — forked from bendc/recursion.js
Functional loop
const loop = (() => {
const recur = (callback, count, i=0) => {
if (i == count-1) return callback(i);
callback(i);
return recur(callback, count, i+1);
};
return (callback, count) => {
if (count > 0) return recur(callback, count);
};
})();
// 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)}},