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, or using the mouse wheel). This technique can be seen as lazy loading for JavaScript files, but it should be used with caution. Always verify your website after enabling advanced options that modify your JavaScript files and CSS.
Complianz scripts and styles are essential for managing cookie banners and meeting GDPR requirements. Optimizing, minifying, or delaying these assets can cause a range of issues, both on the frontend (visible to your visitors) and on the backend compliance layer.
Frontend issues include the cookie banner not displaying at all, appearing broken or unstyled, showing in the wrong language, or reappearing on every page visit because consent preferences could not be saved correctly. In some cases, cached scripts may serve an outdated version of the banner, causing mismatches between what visitors see and what your current configuration requires.
Backend/compliance issues include disrupted consent mechanisms where user choices are not properly recorded or passed to third-party scripts, geo-targeting rules failing to apply (for example, showing a banner to visitors who don't legally require one, or skipping it for those who do), and cookie categories not loading in the correct state. All of these can lead to potential non-compliance with privacy regulations such as the General Data Protection Regulation (GDPR), California Consumer Privacy Act (CCPA), and others.
❗️ To maintain proper functionality and keep your setup aligned, exclude Complianz from caching and optimization processes. Below are the steps to exclude Complianz scripts and CSS from common caching and optimization plugins.
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 Premium scripts are not delayed:
complianz-gdpr-premium/pro/tcf/build/index.jscomplianz-gdpr-premium/pro/tcf-stub/build/index.jscomplianz-gdpr-premium/cookiebanner/js/complianz.min.js
For the free version of Complianz, you need to exclude the following script:
complianz-gdpr/cookiebanner/js/complianz.min.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
cmplz_activated_divi_recaptcha- Complianz Premium
complianz-gdpr-premium/pro/tcf/build/index.jscomplianz-gdpr-premium/pro/tcf-stub/build/index.jscomplianz-gdpr-premium/cookiebanner/js/complianz.min.js
- Complianz Free
complianz-gdpr/cookiebanner/js/complianz.min.js
- Click the Save Changes button
cmplz_activated_divi_recaptcha exclusion is particularly important for users working with the Divi sitebuilder, as it resolves issues with rocketlazyloadscript appearing in GTM.js scripts, as advised by WP Rocket support.
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 Premium
complianz-gdpr-premium/pro/tcf/build/index.jscomplianz-gdpr-premium/pro/tcf-stub/build/index.jscomplianz-gdpr-premium/cookiebanner/js/complianz.min.js
- Complianz Free
complianz-gdpr/cookiebanner/js/complianz.min.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 Premium
complianz-gdpr-premium/assets/css/*complianz-gdpr-premium/cookiebanner/css/*
Complianz Freecomplianz-gdpr/assets/css/*complianz-gdpr/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 Premiumcomplianz-gdpr-premium/assets/css/*complianz-gdpr-premium/cookiebanner/css/*
Complianz Freecomplianz-gdpr/assets/css/*complianz-gdpr/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 Premiumcomplianz-gdpr-premium/assets/css/*complianz-gdpr-premium/cookiebanner/css/*
Complianz Freecomplianz-gdpr/assets/css/*complianz-gdpr/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.
