How to add web workers in react components for 3rd party scripts like google tag manager etc..

I have been trying to implement web workers in our static page when I implemented the web workers the main thread got increased to 16SEC and for mobile main thread taking 8SEC and adding few more script's to worker file it's increasing more work thread process I'm no able to figure it out can anyone help me in this ? for both mobile and desktop version it's been different. Thank you in Advance.
11 Replies
Jochem
Jochem17mo ago
I have no direct experience with this issue, or this library, but I've heard others talk about it and generally they're very positive. It might be worth taking a look at Partytown https://partytown.builder.io/
Partytown
Introduction - Partytown
Partytown - Run third-party scripts from a web worker
Jochem
Jochem17mo ago
the elevator pitch says it's hardly more work than adding a script tag to head, and adding a custom attribute to external scripts you want to run in a webworker
Kiran
Kiran17mo ago
Hi @jochemm i have implemented partytown in my web app but few trackers were getting blocked the trackers i have used like Facebook event , GTM , some related to our project
Kiran
Kiran17mo ago
how can i solve this kind of blocking issues ?
Kiran
Kiran17mo ago
https://script.mfilterit.net/ even this tracker getting blocked
Kiran
Kiran17mo ago
Kiran
Kiran17mo ago
Could you please help how can i resolve this issue ?
Jochem
Jochem17mo ago
sorry, I'm not really familiar with how partytown actually works, I haven't used it. Do those requests work without having the scripts run through partytown, just as a test?
Kiran
Kiran17mo ago
yeah they are running yeah thank you very much thumbupthanks
Jochem
Jochem17mo ago
it's potentially still worth checking if partytown has any info on this, see if there's a setting or maybe they've got a discord or something else you can ask on
Kiran
Kiran17mo ago
yeah I'll try on that and check thanks for your time