critical css

Solutions on MaxInterview for critical css by the best coders in the world

showing results for - "critical css"
Yannick
27 Aug 2018
1"above the fold" is html you see on load, like the header
2header > h1 { /* !Critical */ margin: 300px; }//annotated with a comment in main.css
3npm install -g postcss-split main.css insert result main-critical.css in <head><style> 
4<script id="load"> (https://github.com/filamentgroup/loadCSS)("main-critical.css", document.getElementById("load"));
5<script> function insertLink(_url, _media) { 
6 var link = document.createElement('link'); l.rel = 'stylesheet'; l.type = 'text/css'; l.href = _url; l.media = _media;
7 document.getElementsByTagName('head')[0].appendChild(link)}
8function dCss() { insertLink('url', 'all') }
9if (window.addEventListener) {window.addEventListener(
10  'DOMContentLoaded', dCss, false)} else { window.onload=dCss