What?

This module allows developers to use $ to access the jQuery library in the global namespace instead of calling jQuery explicitly or passing $ as a parameter into your closures.

Why?

Originally, I was annoyed about the change in Drupal 7 (http://drupal.org/node/1407256) that caused Drupal to noconflict() jQuery by default. This was a code migration headache and an inconvenience when it came to using most snippets of jQuery found in example documentation or in snippets on the web.

Now, as I have come to better understand javascript architecture, the value in noconflicting jQuery seems clear, and the only genuine purpose I can give to this module is as a convenience to those who are still annoyed by the minor hoops required to use jQuery "normally".

Should I?

You're OK to use this module if:
1. You don't expect to use any other javascript library that uses the global $ (Prototype, MooTools, maybe some others).
2. You don't need to use different versions of jQuery per page or multiple versions of jQuery throughout your site.

In general this module goes against the now fairly established javascript conventions in Drupal. If those conventions annoy you and you prefer easier access to the $, more power to you. I've been there.

How?

How does it work? The module implements hook_js_alter and injects a js file that re-assigns the global $ to point to jQuery. This happens immediately after misc/drupal.js (drupal.init.js in D8) is loaded (which is where jQuery.noConflict is called) so any other javascript in the site can utilize it, even other scripts that gets added in hook_js_alter should be fine.

Special thanks to sun for collaboration and lending expertise.

Project Information

Downloads