PluginProbe
EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant / 2.0.2
EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant v2.0.2
2.0.4 2.0.3 2.0.2 2.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2 1.3 2.0.0
easyfonts / assets / frontend / async-blocker.min.js

async-blocker.min.js in EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant 2.0.2, at assets/frontend/async-blocker.min.js

1 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(){"use strict";var e=window.EasyFontsAsync;if(e&&e.endpoint){var t=["fonts.googleapis.com","fonts-api.wp.com"],n={};if(s(Node.prototype,"appendChild"),s(Node.prototype,"insertBefore"),window.MutationObserver){var o=new MutationObserver(function(e){for(var t=0;t<e.length;t++)for(var n=e[t].addedNodes,o=0;o<n.length;o++)"LINK"===n[o].tagName&&i(n[o])});try{o.observe(document.documentElement,{childList:!0,subtree:!0})}catch(e){}}var r=null,a={};"loading"!==document.readyState?c():document.addEventListener("DOMContentLoaded",c),window.addEventListener("load",function(){c(),d()})}function i(e){try{var o=e.getAttribute?e.getAttribute("href"):e.href;if("LINK"===e.tagName&&function(e){if(!e||"string"!=typeof e)return!1;for(var n=0;n<t.length;n++)if(-1!==e.indexOf(t[n]+"/css")||-1!==e.indexOf(t[n]+"/icon"))return!0;return!1}(o))return(r=o)&&!n[r]&&(n[r]=!0,d()),e.setAttribute("data-easyfonts-async","1"),e.setAttribute("media","max-width:1px"),e.setAttribute("href","data:text/css,"),e.rel="preload",!0}catch(e){}var r;return!1}function s(e,t){if(e&&e[t]&&!e[t].__efPatched){var n=e[t];e[t]=function(e){try{e&&"LINK"===e.tagName&&i(e)}catch(e){}return n.apply(this,arguments)},e[t].__efPatched=!0}}function c(){for(var e=document.querySelectorAll('link[rel="stylesheet"],link[as="style"]'),t=0;t<e.length;t++)e[t].getAttribute("data-easyfonts-async")||i(e[t])}function d(){r&&clearTimeout(r),r=setTimeout(u,800)}function u(){var t=[];if(Object.keys(n).forEach(function(e){a[e]||(t.push(e),a[e]=!0)}),t.length){var o=JSON.stringify({urls:t}),r=e.endpoint+"?_wpnonce="+encodeURIComponent(e.nonce);if(navigator.sendBeacon)navigator.sendBeacon(r,new Blob([o],{type:"application/json"}));else try{var i=new XMLHttpRequest;i.open("POST",r,!0),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("X-WP-Nonce",e.nonce),i.send(o)}catch(e){}}}}();