Created
September 7, 2018 12:53
-
-
Save lastguest/a6fa9e6d14f7ba7b5c67bcfc95191625 to your computer and use it in GitHub Desktop.
[JS] TypeKit Local Caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Questo codice si salva in localStorage le risorse interne di TypeKit | |
evitando il roundtrip di chiamata e il FOS. | |
Incollare lo snippet PRIMA del blocco : | |
<script src="https://use.typekit.net/gls5dvn.js"></script> | |
<script>try{Typekit.load({ async: true });}catch(e){}</script> | |
--> | |
<script>/* TypeKit */ | |
!function(e,t,n,a,r,c,l,s,o){l=a[r],l&&(s=e.createElement("style"), | |
s.innerHTML=l,e.getElementsByTagName("head")[0].appendChild(s), | |
e.documentElement.className+=" wf-cached"),o=t[n],t[n]=function(e,p,u,i){ | |
if("string"==typeof p&&p.indexOf(c)>-1){try{u=new XMLHttpRequest, | |
u.open("GET",p,!0),u.onreadystatechange=function(){try{4==u.readyState | |
&&(i=u.responseText.replace(/url\(\//g,"url("+c+"/"),i!==l&&(a[r]=i))} | |
catch(e){s&&(s.innerHTML="")}},u.send(null)}catch(d){}t[n]=o}return | |
o.apply(this,arguments)}}(document,Element.prototype,"setAttribute", | |
localStorage,"tk","https://use.typekit.net")</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment