-
-
Save tbuchanan/c61a536576b654c93969 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$critical-css-only:true !default; | |
@mixin critical($critical-only:true){ | |
@if (($critical-css-only and $critical-only) or (not $critical-css-only and not $critical-only)){ | |
@content; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@include critical(true){ | |
// This is critical CSS as it's likely to be above-the-fold | |
.logo{ | |
color:red; | |
} | |
} | |
@include critical(false){ | |
// This is non-critical CSS as it's likely to be below-the-fold | |
.footer{ | |
color:blue; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.logo{ | |
color:red; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "critical"; | |
@import "screen"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Demo</title> | |
<style> | |
// Critical.css content rendered here using https://github.com/ixti/jekyll-assets | |
// Alternatively https://github.com/jgallen23/grunt-inline-css could be an option | |
{% asset critical.css %} | |
</style> | |
</head> | |
<body> | |
<!-- Non-critical.css before closing body tag --> | |
<link rel="stylesheet" href="non-critical.css" /> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.footer{ | |
color:blue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$critical-css-only:false; | |
@import "critical"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment