PluginProbe
EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant / 2.0.4
EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant v2.0.4
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 / beacon.min.js

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

1 lines 2.9 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.EasyFontsBeacon;if(e&&e.endpoint&&document.fonts){var t=/^(serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-(?:serif|sans-serif|monospace|rounded)|-apple-system|blinkmacsystemfont|"?segoe ui"?|helvetica|helvetica neue|arial|times new roman|georgia|courier new|inherit|initial|revert|unset|emoji|math|fangsong)$/i,n=!1;document.fonts.ready.then(function(){setTimeout(a,1500)}),window.addEventListener("pagehide",a),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&a()})}function o(e){return(e||"").trim().replace(/^["']|["']$/g,"")}function i(e){return"normal"===e?"400":"bold"===e?"700":String(e||"400")}function a(){if(!n){n=!0;try{!function(t){if(t.rendered.length||t.preload.length){var n=JSON.stringify({route:e.route,device:e.device,rendered:t.rendered,preload:t.preload,unload:t.unload}),o=e.endpoint+(-1===e.endpoint.indexOf("?")?"?":"&")+(e.token?"_eftoken="+encodeURIComponent(e.token):"_wpnonce="+encodeURIComponent(e.nonce));if(navigator.sendBeacon)navigator.sendBeacon(o,new Blob([n],{type:"application/json"}));else{var i=new XMLHttpRequest;i.open("POST",o,!0),i.setRequestHeader("Content-Type","application/json"),e.token||i.setRequestHeader("X-WP-Nonce",e.nonce),i.send(n)}}}(function(){var e={},n={},a={},r=window.innerHeight||document.documentElement.clientHeight;document.fonts.forEach(function(n){if("loaded"===n.status){var a=o(n.family);if(a&&!t.test(a)){var r=i(n.weight),s=n.style||"normal";e[a]=e[a]||{},e[a][r+"|"+s]=!0}}});var s=document.querySelectorAll("h1,h2,h3,h4,h5,h6,p,a,span,li,td,th,caption,button,label,input,textarea,select,option,blockquote,figcaption,figure,dl,dt,dd,summary,details,strong,b,em,i,u,mark,small,cite,q,code,pre,abbr,time,address,legend,output,div"),l=Math.min(s.length,3e3);function c(e,o,s,l){if(e&&!t.test(e)){var c=e+"|"+i(o)+"|"+(s||"normal");n[c]=!0,l&&l.top<r&&l.bottom>0&&l.width>0&&l.height>0&&(a[c]=!0)}}for(var d=0;d<l;d++){var u=s[d];if(u.value||u.textContent&&u.textContent.trim()){var f=u.getBoundingClientRect(),m=getComputedStyle(u);c(o((m.fontFamily||"").split(",")[0]),m.fontWeight,m.fontStyle,f);var p=getComputedStyle(u,"::before");p&&p.content&&"none"!==p.content&&"normal"!==p.content&&c(o((p.fontFamily||"").split(",")[0]),p.fontWeight,p.fontStyle,f);var h=getComputedStyle(u,"::after");h&&h.content&&"none"!==h.content&&"normal"!==h.content&&c(o((h.fontFamily||"").split(",")[0]),h.fontWeight,h.fontStyle,f)}}var y=[];Object.keys(a).forEach(function(e){var t=e.split("|");y.push({family:t[0],weight:t[1],style:t[2]})});var g=[];return Object.keys(e).forEach(function(t){Object.keys(e[t]).forEach(function(e){var o=e.split("|"),i=t+"|"+o[0]+"|"+o[1];n[i]||g.push({family:t,weight:o[0],style:o[1]})})}),{rendered:Object.keys(n).map(function(e){var t=e.split("|");return{family:t[0],weight:t[1],style:t[2],above_fold:a[e]?1:0}}),preload:y,unload:g}}())}catch(e){}}}}();