I managed to persuade Primary Technology to buy a TypeKit account for the company to use, so I decided what better way to test it than use it globally on PrimaryBlogger in the admin bar and admin dashboard area.
Here’s how I added the code to load when the admin menu bar was showing only, if it’s disabled then the code won’t display (this is useful as we like to keep static file requests to a minimum):
function typekit_admin_menu() { ?> (function() { var config = { kitId: 'typekitidhere', scriptTimeout: 3000 }; var h=document.getElementsByTagName("html")[0];h.className+=" wf-loading";var t=setTimeout(function(){h.className=h.className.replace(/(\s|^)wf-loading(\s|$)/g," ");h.className+=" wf-inactive"},config.scriptTimeout);var tk=document.createElement("script"),d=false;tk.src='//use.typekit.net/'+config.kitId+'.js';tk.type="text/javascript";tk.async="true";tk.onload=tk.onreadystatechange=function(){var a=this.readyState;if(d||a&&a!="complete"&&a!="loaded")return;d=true;clearTimeout(t);try{Typekit.load(config)}catch(b){}};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(tk,s) })(); <?php } add_action('admin_bar_menu', 'typekit_admin_menu');