Excluding Complianz JavaScript from Caching and Optimization Plugins
If you encounter issues with JavaScript delay in your caching or optimization plugins, you can exclude Complianz from this process. This guide explains how to whitelist Complianz scripts across various plugins, including WP Rocket and LiteSpeed.
The keywords for exclusion are:
- complianz
- cmplz
Additionally, you need to exclude specific Complianz JavaScript files. Use the following paths to ensure that Complianz scripts are not delayed:
complianz-gdpr-premium/pro/tcf/build/index.js
complianz-gdpr-premium/pro/tcf-stub/build/index.js
Here’s how to do it:
How to Exclude Complianz JavaScript from Optimization in WP Rocket
- In WP Rocket, go to the File Optimization tab.
- Under the JavaScript Files section, check the option to Delay JavaScript Execution.
- In the Exclude JavaScript field, enter the following exclusions:
- complianz
- cmplz
complianz-gdpr-premium/pro/tcf/build/index.js
complianz-gdpr-premium/pro/tcf-stub/build/index.js
- Click the Save Changes button
How to Exclude Complianz JavaScript from Optimization in LiteSpeed
- In LiteSpeed Cache, navigate to Page Optimization.
- Go to the Tuning tab.
- In the JS Excludes field, enter the following exclusions:
- complianz
- cmplz
complianz-gdpr-premium/pro/tcf/build/index.js
complianz-gdpr-premium/pro/tcf-stub/build/index.js
- If you’ve set Load JS Deferred to either Deferred or Delayed under the JS Settings tab, make sure to add these exclusions to the JS Deferred/Delayed Excludes field as well.
- Click the Save Change button
Excluding Complianz CSS from Optimization
In addition to JavaScript files, Complianz CSS files should also be excluded from optimization to prevent layout issues with the cookie banner or other compliance elements. Use the following exclusion paths:
complianz-gdpr-premium/assets/css/*
complianz-gdpr-premium/cookiebanner/css/*
This ensures that your CSS files remain unaffected by optimization processes.
How to Exclude Complianz CSS Files from Optimization in WP Rocket
- In the WordPress admin, go to Settings > WP Rocket > File Optimization.
- If the minification is enabled, please enter the following exclusions:
- cmplz
complianz-gdpr-premium/assets/css/*
complianz-gdpr-premium/cookiebanner/css/*
- Click the Save Change button on the bottom of the page.
How to Exclude Complianz CSS Files from Optimization in LiteSpeed
- In the WordPress admin, go to LiteSpeed Cache > Page Optimization.
- Under the Tuning – CSS tab, enter the following keywords in the CSS Excludes and UCSS File Excludes and Inline fields:
- cmplz
complianz-gdpr-premium/assets/css/*
complianz-gdpr-premium/cookiebanner/css/*
- Click Save Changes.
Issues with Consent Mode v2 and GTM4WP
When using Consent Mode v2 with Complianz in conjunction with GTM4WP (Google Tag Manager for WordPress), some users encounter issues, particularly with e-commerce conversions. These issues are typically caused by conflicts with caching plugins like WP Rocket, rather than the Complianz plugin itself.
How to Fix the Issue in WP Rocket
To resolve this issue in WP Rocket, follow these steps:
- Navigate to Settings in WP Rocket.
- Click on File Optimization.
- Scroll down to the JavaScript section.
- Ensure that Delay JavaScript Execution is enabled.
- Click on Plugins and locate the GTM4WP scripts.
- Add the GTM4WP script to the exclusion list to prevent it from being delayed.
Here’s a screenshot to illustrate this process:
If these steps don’t resolve the issue, 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.