Keeps a site's Typekit in localStorage and injects it on page load. Completely eliminates the annoying Flash Of Invisible/Unstyled Text and provides better UX for slow or offline connections.
The same requests are sent as in loading a Typekit regularly, and the Typekit embed code is unaltered. However, using this script may still violate the Typekit Terms Of Use.
Copy the contents of typekit-cache.min.js right before your Typekit (advanced) embed code. That's it, your website should be caching your Typekit happily.
<script>
!function(e,t,n,a,r,s,l,p){ // ...
</script>
<script>
(function(d) {
var config = {
kitId: 'abcd1234',
scriptTimeout: 3000
},
h=d.documentElement, // ...
})(document);
</script>Works in recent Firefox, Chrome, Safari, and IE.
Please contribute issues and PRs if you find any quirks.
Check the unminified, commented typekit-cache.js for more information.
Typekits may be quite large, and the performance impact of injecting them as inline stylesheets is not well tested.
The minified version is built using uglifyjs typekit-cache.js -o typekit-cache.min.js --compress --mangle.
Thanks!