Uncaught ReferenceError: CRM is not defined

Created on 26 March 2025, about 1 month ago

1.0 Problem/Motivation
When JS aggregation is enabled, sometimes `webform_civicrm_payments.js` loads before the `CRM` object is instantiated. This has probably escaped notice because we generally develop with JS aggregation disabled.

It appears to be this portion of the code:

      if (typeof CRM.payment === 'undefined') {
        CRM.payment = payment;
      }
      else {
        $.extend(CRM.payment, payment);
      }

2.0 Detailed steps to reproduce (embed screenshots)
I don't have sufficient details, other than that you must have payment enabled on your form and JS aggregation must be enabled.

3.0 Proposed resolution
I guess because core's `civicrm.libraries.yml` doesn't define the JS, there's no way to guarantee that this runs after the CRM object is created.

πŸ› Bug report
Status

Active

Version

6.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States MegaphoneJon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024