Keeps a site's Typekit in localStorage and injects it on page load, eliminating the Flash Of Invisible/Unstyled Text.
Switch branches/tags
Nothing to show
Clone or download
morris Merge pull request #16 from morris/revert-14-patch-1
Revert "package.json: switch to uglyfy.js 2.7.5 from 2.4", fix #15
Latest commit 1ccd03d Feb 6, 2017

Typekit Cache

Revision 13

Keeps a site's Typekit in localStorage and injects it on page load. Eliminates the annoying Flash Of Invisible/Unstyled Text (FOUT) 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.

  !function(e,t,n,a,c,l,m,o,d,f,h,i){ /* ... */ }( /* ... */ );
  (function(d) {
    var config = {
      kitId: 'abcd1234',
      scriptTimeout: 3000
    h=d.documentElement, // ...


The regular Typekit behavior is not modified at all. Exceptions visible in the console (e.g. if the storage is not available) can be safely ignored. However, you should use separate <script> tags to ensure the Typekit embed code is still run if an exception occurs.

In addition to the regular wf-* classes, the wf-cached class is added to the <html> tag on cache hit.

To use sessionStorage instead, just replace the localStorage reference.


Make sure PRs contain an updated minified version. Run npm run prepublish to build it.