Skip to content

Instantly share code, notes, and snippets.

@KingScooty
Last active March 7, 2016 14:36
Show Gist options
  • Save KingScooty/f8eb664f2ad02cab003d to your computer and use it in GitHub Desktop.
Save KingScooty/f8eb664f2ad02cab003d to your computer and use it in GitHub Desktop.
Make Typekit non-blocking for smaller screens and serve up 2 different kits
<script>
var kit;
// Adjust the width threshold
if( window.innerWidth < 800 ) {
//Replace this with your mobile Typekit code
kit = 'xxxxx';
document.write('\x3Cscript src="//use.typekit.net/'+ kit +'.js" onload="try{Typekit.load();}catch(e){}" async>\x3C/script>');
} else {
//Replace this with your desktop Typekit code
kit = 'xxxxx';
document.write('\x3Cscript src="//use.typekit.net/'+ kit +'.js">\x3C/script>');
document.write('\x3Cscript>try{Typekit.load();}catch(e){}\x3C/script>');
};
</script>
@renatocarvalho
Copy link

Hey there, is this script still up-to-date?

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