Slow Script execution
I am using the GA4 module. My current concern is that the scripts associated with the GA4 are running on the main thread and slow the rendering of the page. Google page speed insights for instance indicates that 557ms are used by both JS.
Is there a way that you could to have the JS from GA4 running on a separate thread? Using partytown for instance? Any other possibilities that could increase PageSpeed Insights score.
-
Official comment
Our Google Analytics 4 extension loads the Google Tag Manager script into the <head> section of the page, as is required by Google. It does not stray from or alter this implementation in any way, and your Magento instance would treat it as it would any script loaded directly into the page head.
The speed of the execution depends on a number of factors, one of which is the number of tags in the container, as well as their content. HTML-heavy custom tags will undoubtedly bring the speed down.
A potential speed increase can be seen by using the Measurement Protocol functionality, available in the PRO version of the extension, which can ensure that only the Page View tag is fired client-side, while the rest of the events are fired server-side. More details about the feature can be found on the extension's Product Page.
Alternatively, you can try other 3rd party methods or integrations to move the execution from the main thread, however, we're not able to provide feedback on those, or confirm compatibility.Comment actions
Please sign in to leave a comment.
Comments
1 comment