Javascript Delay in WP Rocket and other Caching and Optimization Plugins

Delay JavaScript Execution improves performance by delaying the loading of all JavaScript files and inline scripts until there is a user interaction (e.g. moving the mouse over the page, touching the screen, scrolling, pressing a key, scrolling with the mouse wheel).  This can be seen as lazy loading for Javascript files but should be used with caution. Always check your website afterwards, if you enable advanced options that modify your javascript files.

Excluding Complianz Javascript

If a problem occurs with Javascript delay in your caching plugins, this is how you exclude Complianz in WP Rocket. Based on the syntax used by your plugin, you’re looking to exclude the complianz.js and complianz.min.js files. Just add the word “complianz”:

complianz

To delay inline scripts, or when timing issues occur on placeholders. You can add:

cmplz
Example from Complianz’s WP Rocket settings

Issues with Consent Mode v2 and GTM4WP

Some users have encountered problems when setting up Consent Mode v2 with Complianz while using GTM4WP (Google Tag Manager for WordPress). These issues, particularly with e-commerce conversions, are not caused by the Complianz plugin but may arise due to caching plugins like WP Rocket.

How to Fix the Issue in WP Rocket

To fix this issue in WP Rocket, follow these steps:

  1. Navigate to Settings in WP Rocket.
  2. Click on File Optimization.
  3. Scroll down to the JavaScript section.
  4. Ensure that “Delay JavaScript Execution” is enabled.
  5. Click on Plugins and locate the GTM4WP scripts.
  6. Add the GTM4WP script to the exclusion list to prevent them from being delayed.

 

Here’s a screenshot to illustrate this process:

If these steps don’t resolve the problem, we recommend contacting the support teams for GTM4WP or WP Rocket for further assistance.

If you have an exclusion syntax for another caching plugin or want to report a compatibility issue. Please log a support ticket.

Join 1M+ users and install The Privacy Suite for WordPress locally, automated or fully customized, and access our awesome support if you need any help!

Complianz has received its Google CMP Certification to conform to requirements for publishers using Google advertising products.