Google Tag Manager – Reduce JavaScript execution time
-
Please go to ‘GTM Kit > Help > Support > Share system data with the GTM Kit support team’ and enter the support ticket: FS819-DAC86
hi,
I have just sent, Since we are on Woocommerce, Shall we need to Activate the WooCommerce integration also or its not mandatory.
Regards,
You should activate the WooCommerce integration or you will miss out on a lot of valuable data.
I see that you have enabled the option GTM Kit > General > Container > load_delayed_js event, which will fire the event ‘load_delayed_js event’ on page load. If you combine this with delaying JavaScript execution in WP Rocket > File optimization > Delay JavaScript execution the event ‘load_delayed_js’ event will be delayed until user interaction.
If you combine your current triggers in Google Tag Manager with the ‘load_delayed_js’ event this means that the tags will be delayed until user interaction and this will improve your page speed score.
If you are not already using ‘Delay JavaScript Execution’ you should be aware that it may break some funcitonality so you have test and tweak the configuration of it.
I have read the message and its already configured as per your recommendations –
load_delayed_js event is ON?Delay JavaScript execution in ON in WP rocket.
What else are you proposing to change?I have just tested your site and load_delayed_js is firing on page load before any user interaction. This means that WP Rocket is not delaying the script that is firing the event. Either there is a problem with your WP Rocket configuraion or something else is triggering the Delay JavaScript Execution to trigger.
that is what we are not able to understand since its delaying to load our site
Google Tag Manager?tag-manager?
1,688?ms
1,524?ms
109?ms- This reply was modified 3 months, 1 week ago by myithubau.
The source code of your site shows that the script is set to be dalayed
<script type="rocketlazyloadscript" id="gtmkit-delay-js-before"> dataLayer.push({"event" : "load_delayed_js"}); </script>
The delay function in WP Rocket is based on events like “mouseover”, “keydown”, “touchstart”, “touchmove”, “wheel” and if any of theese interaction events are triggered the delayed scripts will be excecuted. Other scripts/plugins may trigger these events causing the excecution, so this is really hard to debug.
Your problem is related to WP Rocket so should reach out the the WP Rocket support. I’m afraid I can’t help you any further.
hi Torben,
Please check response from WP Rocket
I’ve checked your website and seems to be there are some GTMkit scripts that are not being delayed, take a look:
The scripts on the red squares are not delayed:
Full-size image here: https://i.imgur.com/xI4T0Pd.png
Those scripts (which in turn are instantiating GTM scripts) are being excluded from Delay JavaScript execution because the
data-nowprocket
attribute has been added to them:Full-size image here: https://i.imgur.com/iiJlSJy.png
Further information in this article.
And this attribute it’s being added by GTMKit, in this function:
Full-size image here: https://i.imgur.com/QxaAmkw.png
That is expected and as it should be.
Your problem is that the following script should be delayed and it looks like it is beeing delayed. However something on you site is triggering interaction causing it to load immediately.
<script type="rocketlazyloadscript" id="gtmkit-delay-js-before"> dataLayer.push({"event" : "load_delayed_js"}); </script>
Hi, I have updated your plugin and Wp rocket also, the issue seems to have fixed. Can you please recheck ?
Your score is 86: https://pagespeed.web.dev/analysis/https-www-myithub-com-au/l3qx9asqsk?form_factor=mobile
You just need to check if you are receiving data in Google Analytics
Closing this
hi,
Its not fixed still.
The issue with your website are these scripts:Full-size image here: https://i.imgur.com/Dq57qZ0.png
Especially the GTM ones. And those scripts are being triggered by these inline scripts, which are being excluded from Delay JavaScript execution by adding the attribute data-nowprocket:
Full-size image here: https://i.imgur.com/whXoLKc.png
I will try to explain myself as clearly as possible:
For WP Rocket to be able to delay the execution of a script, that script must be present in the HTML of the page, only then WP Rocket can add the RocketLazyloadscript attribute to delay it, but if that script is not present in the HTML but is dynamically triggered (as in this case) by a script that was itself excluded from the feature, then WP Rocket will not be able to delay it and therefore that script will end up affecting your score if it consumes too much execution time.
Hi,
It has been 4 days since I am waiting for your response.
he LCP score is indeed mainly affected by the loading of JavaScript files, as you have pointed out earlier in the ticket. On your website that JavaScript code comes primarily from the Google Tag Manager implementation. You have a plugin named gtm-kit with which you load various analytics JavaScript code and about 85% of the JavaScript loading time is related to code brought through the Google Tag Manager:
https://www.myithub.com.au/Screenshot%202024-08-21%20at%2018.44.24.png
For the sake of testing purposes, I disabled temporarily the gtm-kit plugin and retested the mobile performance with the Google PageSpeed Insights too. As you can see from the results below, the mobile score was instantly increased to 73:
https://pagespeed.web.dev/analysis/https-www-myithub-com-au/qk9m8azo1y?form_factor=mobile
- You must be logged in to reply to this topic.