(function(){ let enhancement = { id: 'fast' }; const values = ['downlink', 'downlinkMax', 'effectiveType', 'rtt', 'saveData', 'type']; const minDownlink = 0.7; const maxRtt = 150; try { const connection = window.navigator.connection || {}; values.forEach(v => { enhancement[v] = connection[v]; if (enhancement[v] === undefined){ enhancement[v] = null; } }); const override = window.location.search.match(/enhancementId=([^&]+)/); if (override && override[1]) { enhancement.id = override[1]; } else { const isMobile = window.navigator.userAgent.match(/Android|iPhone|Mobi/); const { downlink, rtt, saveData } = enhancement; const isLowBandwidth = (downlink && (downlink <= minDownlink)) || (rtt && (rtt >= maxRtt)); if (isMobile && (saveData || isLowBandwidth)) { enhancement.id = 'slow'; } } } catch (ex) { enhancement.id = 'fast'; } window.enhancement = enhancement; })();

WHMCS-bridge

WordPress and WHMCS integration by i-Plugins