Skip to content

Instantly share code, notes, and snippets.

@alexcarpenter
Forked from shelldandy/typekit.html
Created September 27, 2017 12:23
Show Gist options
  • Save alexcarpenter/9b8cd3f3f04add4d56016a718c28c614 to your computer and use it in GitHub Desktop.
Save alexcarpenter/9b8cd3f3f04add4d56016a718c28c614 to your computer and use it in GitHub Desktop.
Master Race Typekit Solution by Glen Maddern
<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