JS is not compressed in garland theme

Comments

prathamesh.save’s picture

When I include the JS file through theme.info, then none of the javascript is included in civicrm and the console shows cj is not defined and other js errors.
My file system is private.
I am using civicrm 4.1.6 and drupal 6.26.
I have latest version of this module installed.

prathamesh.save’s picture

Title: JS not compressed in Garland » Js added by theme breaks
p5systems’s picture

Status: Closed (fixed) » Fixed

Hello prathamesh.save,
You can add js in your theme through drupal_add_js('jsfolder/yourjs.js'); in your templete.php file of the theme.

Category: support » bug
Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

flug’s picture

Component: JS Compression » Code
Issue summary: View changes

Problem when running advagg and civicrm together: "console shows cj is not defined and other js errors." Basically no js or ajax works within CiviCRM. Contribution forms are missing the credit card fields. Civicrm Dashboard items don't show and give a error indicating js must be turned on. Etc.

The root of this problem has to do with the fact that Drupal & CiviCRM use different versions of JQuery. CiviCRM calls its version cj and prefixes all jquery calls with cj to differentiate. Whether this works seems to be very dependent on the order in which the jquery and other js modules are loaded. If you look at the javascript console or errors you see see a large number of "cj not defined" errors.

Here is how I solved (using Drupal 6, Civicrm 4.2, Jquery update, advagg modules):

- You'll need the module weights module enabled (it's part of drupal core)
- Go to admin/build/modules
- Set weight for JQuery UPdate to 98
- Weight for Advanced CSS/JS Aggregation to 99
- Weight for CiviCRM to 100

Depending on what other modules you have & issues regarding their relative weights, you might need to adjust this a bit--maybe it is 298, 299, and 300 instead of 98, 99, 100. But the basic idea is that both JQuery Update & AdvAgg must be loaded BEFORE CiviCRM. AdvAgg needs to be loaded AFTER most other modules but before CiviCRM.

Out of the box AdvAgg has weight of 250, putting it after CiviCRM. This causes the problem. Adjusting the module weights appears to solve it.

Related topics from the CiviCRM message boards:

http://forum.civicrm.org/index.php?topic=23203.0 (AdvAgg vs Civicrm & javascript)
http://forum.civicrm.org/index.php?topic=21761.0 (Potential issues/solutions re: CiviCRM & Jquery update)