Last active
March 1, 2017 02:46
-
-
Save seanogdev/0f01b307dfe8c7c1c634e39a0bb25547 to your computer and use it in GitHub Desktop.
Critical CSS in Twig
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
| {% set styleSite = rev("css/style.css") %} | |
| {% if stylesLoaded == true %} | |
| <link rel="stylesheet" href="{{ styleSite }}" /> | |
| {% else -%} | |
| <style>{{ craft.inlin.er('/assets/css/critical/' ~ critical ~ '.css') | raw }}</style> | |
| {% include 'includes/scripts/_async-assets' only %} | |
| <script> | |
| var stylesheet = loadCSS('{{ styleSite }}'); | |
| onloadCSS( stylesheet, function() { | |
| document.cookie = "css-loaded=1;"; | |
| }); | |
| </script> | |
| <noscript> | |
| <link rel="stylesheet" href="{{ styleSite }}" /> | |
| </noscript> | |
| {% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment