Joseph Rex
I'm here for the popcorn ;)
WHAT IS CRITICAL CSS?
Critical CSS are the CSS rules that handles "above the fold" contents of web pages. Web pages will remain blank on client side till browsers parse and download the stylesheets. By inlining the CSS responsible for parts visible to users before any scrolling is done, the first contents to be displayed wouldn't rely on the CSS to be requested on HTTP request of the stylesheets.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
...
<header>
<section class="below">
...
</section>
</body>
</html>
HTML
header{ background: white; }
.below{ background: #D353EC; }
style.css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
header{ background: white; }
</style>
</head>
<body>
<header>
...
<header>
<section class="below">
...
</section>
<!-- Load non-critical CSS Asynchronously -->
<script>
loadCSS('style.css');
</script>
<noscript>
<link rel="stylesheet" href="style.css">
</noscript>
</body>
</html>
HTML
.below{ background: #D353EC; }
style.css
Why should non-critical CSS be loaded asynchronously?
Since the critical CSS is being loaded an we're trying to reduce the HTTP request made before the page is rendered, this is required
I used loadCSS by Filament Group for this
https://github.com/filamentgroup/loadCSS/blob/master/loadCSS.js
Every front-end purist does. We can separate our critical styles from our inline style by taking advantage of features offered by a pre-processor like SASS
The compass extension : jacket (https://github.com/Team-Sass/jacket) can be used to dress the CSS such that critical CSS is separated from non-critical CSS
@joerex101
By Joseph Rex
critical-css