Search code examples
jquerydrupaldrupal-6

Drupal and the latest jQuery


I need to use the latest version of jQuery in my Drupal.

jQuery update module is not enough because it doesn't update jquery to its latest version.

Is there anyway to use the latest version of jquery in the front-end, and the drupal included version for the back-end ?

Should I work on the theme templates files ? Is this going to cause issues ?

thanks


Solution

  • Drupal includes the jQuery library in each page that uses JavaScript. The only way to use a more recent version of jQuery than the one Drupal comes with is to install jQuery Update, which provides also a script for compatibility with scripts using an older version of the library. The jQuery Update module updates:

    • Drupal 5 to jQuery 1.2.6
    • Drupal 6 to jQuery 1.3.2
    • Drupal 7 to jQuery 1.5.2, and jQuery UI 1.8.11

    If you are going to simply replace the jQuery library contained in /misc, then Drupal scripts will stop to work (I tried doing that, and that was the result). Loading a more recent version after Drupal loaded the library in /misc will also cause problems.

    To complete the information, there was a module that came with its own version of the jQuery library that was then binded to $ui; in that way, other code would still use the default jQuery library, while your module / theme would use the more recent library. The module simply loaded its own version of jQuery, and then executed the following JavaScript line:

    window.$ui = jQuery.noConflict(true);
    

    Using the same approach, you would be able to load the latest version of jQuery without creating any conflict with existing modules. This system doesn't work if you are using a module developed from somebody else, and that uses Javascript code that uses $; it works for your custom module/theme you run on your site, though.