Excluding Complianz Scripts and CSS from WP Rocket, LiteSpeed, 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, 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.

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

  1. In WP Rocket, go to the File Optimization tab.
  2. Under the JavaScript Files section, check the option to Delay JavaScript Execution.
  3. 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
  4. Click the Save Changes button

How to Exclude Complianz JavaScript from Optimization in LiteSpeed

  1. In LiteSpeed Cache, navigate to Page Optimization.
  2. Go to the Tuning tab.
  3. 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
  4. 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.
  5. 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

  1. In the WordPress admin, go to Settings > WP Rocket > File Optimization.
  2. If the minification is enabled, please enter the following exclusions:
    • cmplz
    • complianz-gdpr-premium/assets/css/*
    • complianz-gdpr-premium/cookiebanner/css/*
  3. Click the Save Change button on the bottom of the page.

How to Exclude Complianz CSS Files from Optimization in LiteSpeed

  1. In the WordPress admin, go to LiteSpeed Cache > Page Optimization.
  2. 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/*
  3. 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:

  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 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.

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.