Shoora
5/3/2019 - 11:14 AM

Google Web Font Loader with LocalStorage

Google Web Font Loader with LocalStorage

<script>
if (window.localStorage && window.localStorage._gf_cache) {
   document.documentElement.classList.add('wf-active');
   var script = document.createElement('script');
   script.innerHTML = localStorage._gf_cache;
   document.head.appendChild(script);
 }
 window._gfonload = function () {
   var req = new XMLHttpRequest()
   req.addEventListener("load", function () {
     window.localStorage._gf_cache = this.responseText;
   });
   req.open("GET", "https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js");
   req.send();
 };

 WebFontConfig = {
   google: {
     families: ['Droid Sans']
   },
   loading: window._gfonload
 }
</script>
<script async src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>