Created
December 6, 2012 16:36
-
-
Save gosseti/4225858 to your computer and use it in GitHub Desktop.
A Typekit snippet that uses Modernizr.load (yepnope) to asynchronously load webfonts only for in browsers that support @font-face.
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
Modernizr.load([{ | |
test: Modernizr.fontface, | |
complete: function() { | |
TypekitConfig = { | |
kitId: 'xxxxxxx', | |
scriptTimeout: 3000 | |
}; | |
(function() { | |
var t = setTimeout(function() { | |
}, TypekitConfig.scriptTimeout); | |
var tk = document.createElement('script'); | |
tk.src = '//use.typekit.com/' + TypekitConfig.kitId + '.js'; | |
tk.onload = tk.onreadystatechange = function() { | |
var rs = this.readyState; | |
if (rs && rs != 'complete' && rs != 'loaded') return; | |
clearTimeout(t); | |
try { Typekit.load(TypekitConfig); } catch (e) {} | |
}; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(tk, s); | |
})(); | |
} | |
}]); |
Author
gosseti
commented
Jun 5, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment