Last active
April 27, 2018 15:25
-
-
Save shelldandy/9119f9803b2a61cfb7cc366ee3836b2d to your computer and use it in GitHub Desktop.
Master Race Typekit Solution by Glen Maddern
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
<head> | |
<script> | |
if (window.localStorage && window.localStorage._tk_cache) { | |
document.documentElement.classList.add('wf-active'); | |
var script = document.createElement('script'); | |
script.innerHTML = localStorage._tk_cache + ";(function () {var timeout = setTimeout(function () {document.documentElement.classList.remove('wf-active');}, 300); Typekit.load({ async: false, active: function () { clearTimeout(timeout); }});})();"; | |
document.head.appendChild(script); | |
} | |
window._tk_onload = function () { | |
var req = new XMLHttpRequest() | |
req.addEventListener("load", function () { | |
window.localStorage._tk_cache = this.responseText; | |
}); | |
req.open("GET", "https://use.typekit.net/XXXXXXXXXXXXXXXX.js"); | |
req.send(); | |
}; | |
</script> | |
<script async src="https://use.typekit.net/XXXXXXXXXXXXXXXX.js" | |
onload="try { Typekit.load({ async: true, loading: window._tk_onload }) } catch (e) {}"></script> | |
</head> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That goes right before closing the HEAD element, replace the XXXX with your actual typekit code