Created
August 10, 2012 03:59
-
-
Save asabaylus/3310929 to your computer and use it in GitHub Desktop.
Load TypeKit using jQuery
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
(function() { | |
var config = { | |
kitId: "XXXXXXX", | |
scriptTimeout: 3000 | |
} | |
, l = "wf-loading" | |
, d = "wf-inactive" | |
, h = $("html").addClass(l) | |
, t = setTimeout(function(){ | |
h.removeClass(l).addClass(d); | |
}, config.scriptTimeout ); | |
$.ajax({ | |
url: '//use.typekit.net/' + config.kitId + '.js', | |
dataType: 'script', | |
cache: true | |
}) | |
.done(function() { | |
try { Typekit.load(config); } catch( e ) { return; }; | |
clearTimeout(t); | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Caches the typekit script and defends against broken or missing script