├── .eslintrc.js ├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── bower.json ├── package.json ├── test ├── test.css └── visible.html ├── typekit-cache.js └── typekit-cache.min.js /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true 4 | }, 5 | extends: "eslint:recommended", 6 | parserOptions: { 7 | ecmaVersion: 5 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | test/* linguist-vendored 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ``` 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2015-2019 Morris Brodersen 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ``` 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Typekit Cache 2 | 3 | _Revision 14_ 4 | 5 | **Current Status:** typekit-cache only works for older Typekit installations (using JavaScript). Newer installations use a `` tag; all resources are cached properly by the browser 6 | and served from disk on a revisit. This cannot be further improved so upgrading to the `` embed and removing typekit-cache is recommended. 7 | 8 | --- 9 | 10 | Keeps a site's [Typekit][tk] in `localStorage` and injects it on page load. 11 | Eliminates the annoying Flash Of Invisible/Unstyled Text (FOUT) and provides 12 | better UX for slow or offline connections. 13 | 14 | The same requests are sent as in loading a Typekit regularly, and the Typekit embed code is unaltered. 15 | However, using this script may still violate the [Typekit Terms Of Use][tou]. 16 | 17 | ## Usage 18 | 19 | Copy the contents of [typekit-cache.min.js][min] right before your Typekit (advanced) embed code. 20 | That's it, your website should be caching your Typekit happily. 21 | 22 | ```html 23 | 26 | 35 | ``` 36 | 37 | ## Notes 38 | 39 | The regular Typekit behavior is not modified at all. 40 | Exceptions visible in the console (e.g. if the storage is not available) can be safely ignored. 41 | However, you should use separate ` 9 | 10 | 11 | 12 | 13 |
14 |

Test 

15 |

Test 

16 |
17 | 18 |

19 | 20 | 21 |

22 | 23 |
24 |
25 | 26 |

27 | 28 | 41 | 42 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /typekit-cache.js: -------------------------------------------------------------------------------- 1 | (function( 2 | // Constants 3 | document, 4 | style, 5 | innerHTML, 6 | getElementsByTagName, 7 | // Config 8 | storage, 9 | key, 10 | pattern, 11 | delay, 12 | // Vars 13 | temp, 14 | next, 15 | i, 16 | css 17 | ) { 18 | // If CSS is in cache, append it to in a