1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-11 23:55:16 +01:00

improved typekit snippet

This commit is contained in:
Matthias Kretschmann 2015-06-10 14:52:25 +02:00
parent af6f6e5467
commit deff2a3866

View File

@ -58,9 +58,21 @@
<link rel="stylesheet" href="/assets/css/{{ page.style }}"> <link rel="stylesheet" href="/assets/css/{{ page.style }}">
{% endif %} {% endif %}
<!-- TypeKit --> <!--
<script src="//use.typekit.com/msu4qap.js"></script> TypeKit
<script>try{Typekit.load();}catch(e){}</script> Improved snippet from https://blog.5apps.com/2014/02/21/using-typekit-the-right-way-with-an-improved-loading-script.html
-->
<script>
(function(d) {
var tkTimeout=3000;
if(window.sessionStorage){if(sessionStorage.getItem('useTypekit')==='false'){tkTimeout=0;}}
var config = {
kitId: 'msu4qap',
scriptTimeout: tkTimeout
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+"wf-inactive";if(window.sessionStorage){sessionStorage.setItem("useTypekit","false")}},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+="wf-loading";tk.src='//use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
</script>
<!-- Picturefill --> <!-- Picturefill -->
<script src="/assets/js/picturefill.min.js" async></script> <script src="/assets/js/picturefill.min.js" async></script>