• rcgordon

    (@rcgordon)


    Is integrating Typekit calls with Async JS possible and productive?

    I am currently just hard-coding the provided async Typekit code into my footer.php (which seemed to improve apparent loading time compared to the suggested approach of putting it in the header.php).

    <script type="text/javascript">
    	(function(d) {
    		var tkTimeout=3000;
    		if(window.sessionStorage){if(sessionStorage.getItem('useTypekit')==='false'){tkTimeout=0;}}
    		var config = {
    			kitId: <REDACTED>,
    			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);

    Site: theshelterblog.com

    https://ww.wp.xz.cn/plugins/asynchronous-javascript/

The topic ‘Using Adobe Typekit with Async JS’ is closed to new replies.