Skip to content

Instantly share code, notes, and snippets.

@asabaylus
Created August 10, 2012 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asabaylus/3310929 to your computer and use it in GitHub Desktop.
Save asabaylus/3310929 to your computer and use it in GitHub Desktop.
Load TypeKit using jQuery
(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);
})
})();
@asabaylus
Copy link
Author

Caches the typekit script and defends against broken or missing script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment