Skip to content

Instantly share code, notes, and snippets.

@joshje
Created October 30, 2012 11:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshje/3979740 to your computer and use it in GitHub Desktop.
Save joshje/3979740 to your computer and use it in GitHub Desktop.
Load Fontdeck fonts asynchronously with hidden text timeout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function async(url) {
var a = document.createElement('script');
a.async = true;
a.src = url;
var b = document.getElementsByTagName('script')[0];
b.parentNode.insertBefore(a, b);
}
(function() {
var htmlEl = document.getElementsByTagName('html')[0];
htmlEl.className += ' js wf-loading';
setTimeout(function() {
htmlEl.className = htmlEl.className.replace(' wf-loading', '');
}, 2000);
WebFontConfig = {
fontdeck: { id: 000000 }
}
async('http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js');
})();
</script>
<style>
body {
background: grey;
}
.wf-loading body {
visibility: hidden;
}
</style>
</head>
<body>
Testing testing
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment