Last active
March 7, 2016 14:36
-
-
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
This file contains hidden or 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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there, is this script still up-to-date?