nextjs-google-analytics icon indicating copy to clipboard operation
nextjs-google-analytics copied to clipboard

[Feature Request] Would you consider using PartyTown to load the gtm script?

Open carlos-algms opened this issue 3 years ago • 3 comments

To get better performance and higher Lighthouse scores, it is possible to delegate the third-party scripts to web workers.

That's where PartyTown comes into place.

https://partytown.builder.io/nextjs

carlos-algms avatar Oct 10 '22 08:10 carlos-algms

Hello @carlos-algms , this is a great idea. Let's leave the issue open to see if it gathers some traction, and if so, I'll be happy to work on it or let anyone else do it.

MauricioRobayo avatar Oct 30 '22 02:10 MauricioRobayo

This should definitely be done, as the script will be offloaded to the service-worker on a different thread.

+1

M1ck0 avatar Oct 30 '22 20:10 M1ck0

I think this is not really necessary, since Next.js scripts already have experimental support for PartyTown.

https://nextjs.org/docs/basic-features/script#offloading-scripts-to-a-web-worker-experimental

Edit: I just found out that we need to change some things in order for partytown to communicate with google analytics, so there needs to be some minor changes in order for it to work with webworkers.

ugnmura avatar Jan 06 '23 14:01 ugnmura