Open digitalcortex opened 1 year ago
+1
Adding support for Partytown is fairly straightforward.
It's a matter of setting a special type for the gtag script and notifying Partytown.
export const load = (url, options = {}) => {
return new Promise((resolve, reject) => {
if (typeof document === "undefined") {
return;
}
const head = document.head || document.getElementsByTagName("head")[0];
const script = document.createElement("script");
/* ... */
if (options.partytown) {
script.type = 'text/partytown'; // mark the script for partytown
}
head.appendChild(script);
if (options.partytown) {
window.dispatchEvent(new CustomEvent('ptupdate')); // trigger partytown rescan
}
/* ... */
});
};
need this feature so much
Page speed insights is complaining about Google Analytics module blocking the main thread. I figured that Partytown web worker can help avoid blocking the main thread when using analytics.
Is there any chance it could be supported out of the box?