• Resolved viablethought

    (@viablethought)


    Hello –

    The following error is showing in console and it is preventing other scripts from executing on our site:

    Uncaught ReferenceError: Colcade is not defined

    Line 1887 in frontend.js

    function crResizeAllGridItems() {
    if ( ! typeof jQuery.fn.colcade === "function" || typeof jQuery.fn.colcade === "undefined" ) {
    Colcade.makeJQueryPlugin();
    }
    crResizeAllGridItemsUtil( jQuery(".cr-reviews-grid-inner") );
    }

    Both WordPress and WooCommerce is at the latest versions and running on PHP 8.2

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support pistachio6321

    (@pistachio6321)

    Thank you for reaching out and reporting this issue!

    Could you share a link to the page with this error?

    Thread Starter viablethought

    (@viablethought)

    Hello @pistachio6321

    I just patched it in our client’s child theme using the following code:

    function load_colcade_for_reviews_plugin() {
    wp_enqueue_script(
    'colcade',
    'https://unpkg.com/colcade@0/colcade.js',
    array(),
    null,
    true
    );
    }
    add_action('wp_enqueue_scripts', 'load_colcade_for_reviews_plugin', 5);

    It was causing a conflict with Google Recaptcha and preventing forms from submitting, so we needed to patch it quickly.

    Here is a summary:

    Problem Details:

    • The plugin’s frontend JavaScript calls Colcade.makeJQueryPlugin() without first checking if the Colcade library is loaded.
    • This happens even on pages where there are no review grids or no shortcodes present.
    • As a result, this breaks JavaScript execution globally, even on non-product pages like the homepage, cart, checkout, etc.

    Root Cause:

    • The plugin’s JavaScript file assumes that Colcade will always be available.
    • However, Colcade is only needed when a review grid (e.g., [cusrev_reviews_grid] shortcode) is actually displayed.
    • No conditional loading or existence check is done before calling Colcade methods.

    Temporary Workaround:

    • To prevent JS errors and broken functionality, we had to manually enqueue the Colcade library sitewide via our child theme’s functions.php.
    • However, this is not ideal because it loads an unnecessary asset on every page, negatively impacting performance.

    Recommended Fix:

    • Before calling Colcade.makeJQueryPlugin(), the plugin should first:
      • Check if Colcade is defined (if ( typeof Colcade !== "undefined" )).
      • Only attempt to initialize Colcade when there is a .cr-reviews-grid-inner element present in the DOM.
    • Alternatively, conditionally load Colcade only on pages where it is actually needed (where the shortcode or widget is used).

    This would ensure better performance, avoid unnecessary errors, and reduce resource loading on unrelated pages.

    Thanks

    Plugin Support pistachio6321

    (@pistachio6321)

    Thank you for sharing the additional details. This issue should be resolved in the version 5.76.2. Please install the update and let us know in case of any further issues.

    Thread Starter viablethought

    (@viablethought)

    @pistachio6321

    Thank you for your quick response and attention to this issue, we have updated our client’s site and the new version does resolve this particular issue.

    Have a great day!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Javascript Error: Uncaught ReferenceError: Colcade is not defined’ is closed to new replies.