Skip to content

Instantly share code, notes, and snippets.

View eriktorsner's full-sized avatar

Erik Torsner eriktorsner

  • Stockholm, Sweden
View GitHub Profile
@eriktorsner
eriktorsner / critcss.snippet.js
Last active November 11, 2016 11:02 — forked from james-Ballyhoo/critcss.snippet.js
Based off of https://gist.github.com/PaulKinlan/6284142 , but with support for media queries and dumps css to a textarea in a panel stuck to the top of the page. Only tested in Chrome, uses height of window to determine "critical path".
(function(){
if(document.querySelector("#_CRIT_CSS")){return;}
var container = document.createElement("div");
container.id = "_CRIT_CSS";
container.innerHTML = '<textarea cols=80 rows=20></textarea><button id="CRIT_FIND">Find Critical CSS</button><button id="CRIT_CLOSE">Exit</button>';
container.style.position = "fixed";
container.style.top = 0;
container.style.left = 0;
container.style.right = 0;
container.style.backgroundColor = "#FFF";