WP Rocket compatibility with CookieHub
WP Rocket is a popular caching plugin for WordPress that improves site performance and load times. However, caching can interfere with the CookieHub widget and its features. If not configured correctly, you might experience:
- Delayed loading or initialization of the CookieHub widget
- Cookie blocking not working as expected, which can lead to compliance issues
These issues occur because WP Rocket may serve static versions of JavaScript files instead of the dynamic scripts required by CookieHub.
How to exclude CookieHub scripts from WP Rocket
Follow these steps to prevent conflicts:
- Go to Settings > WP Rocket in your WordPress dashboard.
- Open the File Optimization section and find the JavaScript files options.
- If you enable Minify JavaScript files, Load JavaScript deferred, or Delay JavaScript execution, a text field called Exclude JavaScript Files will appear.
- In the Exclude JavaScript Files field, add these patterns:
cdn.cookiehub.eu/c2/ cookiehub.net/c2/ cookiehub.load googletagmanager.com/gtm.js
These patterns ensure that CookieHub scripts are not cached or optimized.
Note: If you do not use Google Tag Manager for CookieHub, remove googletagmanager.com/gtm.js from the list.
- Save your changes and clear your site cache to apply the settings.
For more details, check WP Rocket’s official guide: Exclude files from Load JavaScript Deferred.