Skip to content

Instantly share code, notes, and snippets.

@germanny
Forked from ericrasch/TypeKit embed code.php
Last active January 3, 2016 11:39
Show Gist options
  • Save germanny/8457087 to your computer and use it in GitHub Desktop.
Save germanny/8457087 to your computer and use it in GitHub Desktop.
<?php
/**
* Delayed loading of typekit scripts vs Flicker-free loading
* Source: https://www.farbeyondcode.com/Delayed-loading-of-typekit-scripts-vs-Flicker-free-loading-5-2304.html
* Avg. Load Time: 66ms; 91ms; 113ms
*/
?>
<script type="text/javascript">
/* <![CDATA[ */
TypekitConfig = {
kitId: 'xxxxxxx'
};
(function() {
var tk = document.createElement('script');
tk.src = '//use.typekit.com/' + TypekitConfig.kitId + '.js';
tk.type = 'text/javascript';
tk.async = 'true';
tk.onload = tk.onreadystatechange = function() {
var rs = this.readyState;
if (rs && rs != 'complete' && rs != 'loaded') return;
try { Typekit.load(TypekitConfig); } catch (e) {}
};
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(tk, s);
})();
/* ]]> */
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment