这是一个确保在 Typekit 服务器关闭时显示浏览器默认字体的修复程序。
<script>
(function(d) {
loadFonts = 1;
if(window.sessionStorage){
if(sessionStorage.getItem('useTypekit')==='false'){
loadFonts = 0;
}
}
if (loadFonts == 1) {
var config = {
kitId: 'XXXXXXXX',
scriptTimeout: 3000,
async: true
},
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='https://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>
<style>
.wf-loading p, .wf-loading h1, .wf-loading h2, .wf-loading h3, .wf-loading h4 {
visibility: hidden;
}
.wf-active p, .wf-active h1, .wf-active h2, .wf-active h3, .wf-active h4 {
visibility: visible;
}
.wf-inactive p, .wf-inactive h1, .wf-inactive h2, .wf-inactive h3, .wf-inactive h4 {
visibility: visible;
}
</style>
您可以阅读有关the full solution in this blog post 的更多信息。