Created
July 16, 2018 02:37
-
-
Save ricardozea/07f4b4d2b435890c44169a661f8f28b2 to your computer and use it in GitHub Desktop.
"CSS is treated as a render blocking resource, which means that the browser won’t render any content until it’s finished loading. So this works great if you’re using fonts from something like Google Fonts or Adobe’s TypeKit, you don’t need to be wait
This file contains 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
<noscript id="deferred-styles"> | |
<link href="https://fonts.googleapis.com/css?family=Ubuntu:300,300i,700,700i" rel="stylesheet"> | |
</noscript> | |
<script> | |
// Load CSS | |
var loadDeferredStyles = function() { | |
var addStylesNode = document.getElementById("deferred-styles"); | |
var replacement = document.createElement("div"); | |
replacement.innerHTML = addStylesNode.textContent; | |
document.body.appendChild(replacement) | |
addStylesNode.parentElement.removeChild(addStylesNode); | |
}; | |
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || | |
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; | |
if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); }); | |
else window.addEventListener('load', loadDeferredStyles); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment