Last active
September 12, 2021 20:57
-
-
Save gr1zix/53ad0a1e5fd68c44c2314a0a5b281eaf to your computer and use it in GitHub Desktop.
Google and custom fonts async loading
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
<!DOCTYPE html> | |
<html lang="en" class="fonts-loading"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
<script type="text/javascript"> | |
// Lib: https://github.com/typekit/webfontloader | |
// Async font loading | |
WebFontConfig = { | |
google: { families: [ 'Arvo:400,400i,700,700i' ] } | |
}; | |
(function() { | |
var wf = document.createElement('script'); | |
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; | |
wf.type = 'text/javascript'; | |
wf.async = true; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(wf, s); | |
setTimeout(function () { | |
document.getElementsByClassName('fonts-loading')[0].classList.remove('fonts-loading'); | |
}, 400); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment