diff --git a/js/consts.js b/js/consts.js index ae14740..415aa23 100644 --- a/js/consts.js +++ b/js/consts.js @@ -1,5 +1,4 @@ export const GA = 'UA-119717465-13'; - export const env = (location.hostname === 'localhost' || location.hostname.endsWith('.netlify.live')) ? 'development' : 'production'; diff --git a/js/index.js b/js/index.js index 1bbe521..d42cd60 100644 --- a/js/index.js +++ b/js/index.js @@ -19,20 +19,19 @@ toggleClass([document.documentElement], { if (typeof GA === 'string' && GA.length !== 0) { const policy = getGooglePolicy(); - scheduler.postTask(() => { - requestIdleCallback(async () => { - const { ga, hasGa } = await importGa(GA, {}, { policy }); - - if (hasGa()) { - ga('create', GA, 'auto'); - ga('set', 'transport', 'beacon'); - ga('send', 'pageview'); - - on('a[rel~="external"]', 'click', externalHandler, { passive: true, capture: true }); - on('a[href^="tel:"]', 'click', telHandler, { passive: true, capture: true }); - on('a[href^="mailto:"]', 'click', mailtoHandler, { passive: true, capture: true }); - } - }); + + scheduler.postTask(async () => { + const { ga, hasGa } = await importGa(GA, {}, { policy }); + + if (hasGa()) { + ga('create', GA, 'auto'); + ga('set', 'transport', 'beacon'); + ga('send', 'pageview'); + + on('a[rel~="external"]', 'click', externalHandler, { passive: true, capture: true }); + on('a[href^="tel:"]', 'click', telHandler, { passive: true, capture: true }); + on('a[href^="mailto:"]', 'click', mailtoHandler, { passive: true, capture: true }); + } }, { priority: 'background' }); } else { createPolicy('goog#html', {});