Back to Community

Troubleshooting Common JavaScript Errors in the GDPR Cookie Compliance Plugin

28 threads Sep 16, 2025

Content

Users of the 'GDPR Cookie Compliance – Cookie Banner, Cookie Consent, Cookie Notice – CCPA, DSGVO, RGPD' plugin often encounter JavaScript errors that can prevent the cookie banner from functioning correctly. These issues typically manifest as console errors related to the plugin's main.js or lity.js files. Based on community reports and solutions, here is a guide to diagnosing and resolving the most frequent problems.

Common JavaScript Errors and Their Causes

The plugin's core functionality relies on JavaScript, and conflicts can arise from various sources. The most common errors include:

  • TypeError: Failed to construct 'URL': Invalid URL: Often caused by an invalid URL configured somewhere in the plugin's settings, such as in a script block or the CDN base URL field.
  • SyntaxError: missing } after property list / Bad control character in string literal: Almost always caused by malformed JSON or JavaScript code inserted into the plugin's Third Party Scripts or Advanced Scripts sections.
  • Uncaught ReferenceError: lity is not defined: This indicates the Lity lightbox library, which powers the modal, failed to load. This can be due to a conflict with a caching plugin, a minification setting, or the plugin being removed while traces remain in cache.
  • TypeError: e(...).hide(...).removeClass is not a function / e.indexOf is not a function: These are typically jQuery compatibility errors. The plugin may be using a deprecated jQuery method that conflicts with newer versions of the library or other scripts on the site.
  • Warning: Avoid serving legacy JavaScript to modern browsers: This is an informational warning, not an error. It occurs because the plugin's core script is written in ES5, not the newer ES6 standard. The 'GDPR Cookie Compliance' team has stated that rewriting the entire plugin would be required to resolve this.

Step-by-Step Troubleshooting Guide

Follow these steps to identify and fix the root cause of your JavaScript error.

1. Basic Conflict Check

First, rule out conflicts with other themes or plugins.

  • Clear all caching: Clear your browser cache, any server-side cache, and your CDN cache.
  • Switch to a default WordPress theme (like Twenty Twenty-Four) temporarily to see if the error persists.
  • Deactivate all other plugins except 'GDPR Cookie Compliance'. If the error disappears, reactivate your plugins one by one to find the culprit.

2. Investigate Custom Scripts

Many syntax errors originate from user-added code.

  • Navigate to GDPR Cookie Compliance -> Third Party Scripts and Advanced Scripts.
  • Remove all scripts from these sections, copy them to a text editor for safekeeping, and save the changes.
  • Clear your cache and check if the error is resolved. If it is, carefully re-add your scripts one at a time, ensuring each is perfectly formatted, to find the problematic one.

3. Check Minification and Concatenation Settings

Aggressive optimization plugins often break JavaScript.

  • If you use a plugin like WP Rocket, WP Optimize, or Autoptimize, find its JavaScript optimization settings.
  • Exclude the plugin's scripts from minification, concatenation, and deferral. The files to exclude are typically:
    • /wp-content/plugins/gdpr-cookie-compliance/dist/scripts/main.js
    • /wp-content/plugins/gdpr-cookie-compliance/dist/scripts/lity.js
  • The 'GDPR Cookie Compliance' team recommends this as a standard practice.

4. Address Lity-Related Errors (lity.js, lity.css)

Problems with the Lity library are common.

  • 404 Errors for lity.css/lity.js: Ensure the plugin is updated to the latest version. If you recently removed the plugin but still see errors, it is almost certainly a caching issue. Purge all caches thoroughly.
  • lity is not defined: Use the provided hook to prevent Lity from loading if you do not need the settings modal after initial consent. Add this code to your theme's functions.php file:
    add_action('gdpr_enqueue_lity_nojs', '__return_false');
    add_action('gdpr_disable_lity_enqueue', '__return_true');

5. Verify jQuery Compatibility

If errors mention deprecated functions like .load() or .indexOf(), a jQuery conflict is likely.

  • Ensure your WordPress core, theme, and other plugins are updated.
  • Do not manually deregister the default jQuery version that comes with WordPress, as the plugin depends on it.
  • These specific issues have been reported to the 'GDPR Cookie Compliance' team for fixing in future updates.

When to Seek Further Help

If none of these steps resolve your issue, the problem may be more specific to your configuration. When seeking help in community forums, be prepared to provide:

  • The exact text of the JavaScript error from the browser console.
  • The URL of your website.
  • A list of the steps you have already taken to troubleshoot.

By methodically working through these common causes, you can usually resolve the JavaScript errors and get your cookie banner working smoothly.

Related Support Threads Support