GA4 How should we actually load it up?
Answered
Irish Setter posted this in #help-forum
Irish SetterOP
Greetings!
My query is specifically about GTag, i'm wondering how we should actually load it up?
I have tested loading it up with async, defer, afterInteractive, and even using the @next/third-party library's GA component but it's still a render blocking resource according to pagespeed.web.dev
Thanks in advance!
My query is specifically about GTag, i'm wondering how we should actually load it up?
I have tested loading it up with async, defer, afterInteractive, and even using the @next/third-party library's GA component but it's still a render blocking resource according to pagespeed.web.dev
Thanks in advance!

Answered by Asian paper wasp
JS is single threaded, so everything will eventually blocks the main thread, just sooner or later.
There is a thing called worker thread that more or less "creates" a secondary thread and allow users to off load unimportant stuff with it. But last time I checked, it is not working well with App Router.
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#offloading-scripts-to-a-web-worker-experimental
There is a thing called worker thread that more or less "creates" a secondary thread and allow users to off load unimportant stuff with it. But last time I checked, it is not working well with App Router.
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#offloading-scripts-to-a-web-worker-experimental
6 Replies
Irish SetterOP
up
Asian paper wasp
JS is single threaded, so everything will eventually blocks the main thread, just sooner or later.
There is a thing called worker thread that more or less "creates" a secondary thread and allow users to off load unimportant stuff with it. But last time I checked, it is not working well with App Router.
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#offloading-scripts-to-a-web-worker-experimental
There is a thing called worker thread that more or less "creates" a secondary thread and allow users to off load unimportant stuff with it. But last time I checked, it is not working well with App Router.
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#offloading-scripts-to-a-web-worker-experimental
Answer
Irish SetterOP
Oooooh! I see, i'll try that approach, thank you
Irish SetterOP
Thanks man! @Asian paper wasp was using app router but it somehow worked still
