The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(analytics): always use defer over async to account for document nav event

+4 -5
+4 -5
quartz/plugins/emitters/componentResources.ts
··· 86 86 componentResources.afterDOMLoaded.push(` 87 87 const gtagScript = document.createElement("script") 88 88 gtagScript.src = "https://www.googletagmanager.com/gtag/js?id=${tagId}" 89 - gtagScript.async = true 89 + gtagScript.defer = true 90 90 document.head.appendChild(gtagScript) 91 91 92 92 window.dataLayer = window.dataLayer || []; ··· 121 121 umamiScript.src = "${cfg.analytics.host ?? "https://analytics.umami.is"}/script.js" 122 122 umamiScript.setAttribute("data-website-id", "${cfg.analytics.websiteId}") 123 123 umamiScript.setAttribute("data-auto-track", "false") 124 - umamiScript.async = true 124 + umamiScript.defer = true 125 125 document.head.appendChild(umamiScript) 126 126 127 127 document.addEventListener("nav", () => { ··· 132 132 componentResources.afterDOMLoaded.push(` 133 133 const goatcounterScript = document.createElement("script") 134 134 goatcounterScript.src = "${cfg.analytics.scriptSrc ?? "https://gc.zgo.at/count.js"}" 135 - goatcounterScript.async = true 135 + goatcounterScript.defer = true 136 136 goatcounterScript.setAttribute("data-goatcounter", 137 137 "https://${cfg.analytics.websiteId}.${cfg.analytics.host ?? "goatcounter.com"}/count") 138 138 document.head.appendChild(goatcounterScript) ··· 173 173 const cabinScript = document.createElement("script") 174 174 cabinScript.src = "${cfg.analytics.host ?? "https://scripts.withcabin.com"}/hello.js" 175 175 cabinScript.defer = true 176 - cabinScript.async = true 177 176 document.head.appendChild(cabinScript) 178 177 `) 179 178 } else if (cfg.analytics?.provider === "clarity") { 180 179 componentResources.afterDOMLoaded.push(` 181 180 const clarityScript = document.createElement("script") 182 181 clarityScript.innerHTML= \`(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; 183 - t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; 182 + t=l.createElement(r);t.defer=1;t.src="https://www.clarity.ms/tag/"+i; 184 183 y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); 185 184 })(window, document, "clarity", "script", "${cfg.analytics.projectId}");\` 186 185 document.head.appendChild(clarityScript)