Skip to content

Instantly share code, notes, and snippets.

@kaspar-allenbach
Last active January 31, 2018 13:28
Show Gist options
  • Save kaspar-allenbach/5ccf69b6f38ff77d0281eca7cf49de3e to your computer and use it in GitHub Desktop.
Save kaspar-allenbach/5ccf69b6f38ff77d0281eca7cf49de3e to your computer and use it in GitHub Desktop.
Prevent FOUT
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script>
WebFont.load({ google: { families: ['Fira Sans:400,700,italic,bolditalic'] } });
WebFontConfig = {
// other options and settings
active: function() {
sessionStorage.fonts = true;
}
}
</script>
<script>
(function() {
if (sessionStorage.fonts) {
console.log("Fonts installed.");
document.documentElement.classList.add('wf-active');
} else {
console.log("No fonts installed.");
}
})();
</script>
<style>
body {
font-family: 'Fira Sans', serif;
font-size: 62.5%;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-weight: 400;
font-style: normal;
}
.wf-loading p,
.wf-loading li,
.wf-loading h1,
.wf-loading h2,
.wf-loading h3,
.wf-loading h4,
.wf-loading h5,
.wf-loading h6,
.wf-loading input,
.wf-loading pbutton,
.wf-loading a {
opacity: 0;
}
.wf-active p,
.wf-active li,
.wf-active h1,
.wf-active h2,
.wf-active h3,
.wf-active h4,
.wf-active h5,
.wf-active h6,
.wf-active input,
.wf-active pbutton,
.wf-active a {
transition: opacity 0.3s linear;
-webkit-transition: opacity 0.3s linear;
-moz-transition: opacity 0.3s linear;
opacity: 1;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment