Created
April 10, 2021 17:11
-
-
Save ihorduchenko/741e527def5e2d953b52624838a90aa5 to your computer and use it in GitHub Desktop.
Critical CSS for deferred styles while page is loading
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
<style id="critical-css"> | |
/* Your styles here */ | |
</style> | |
<script> | |
const criticalStyleTag = document.getElementById('critical-css'); | |
document.addEventListener('DOMContentLoaded', function() { | |
setTimeout(function(){ | |
criticalStyleTag.parentNode.removeChild(criticalStyleTag); | |
}, 2000); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment