Today for a customer I had to use a special plugin for jQuery that needs a jQuery version equal or major than 1.6.1.
As you know Drupal 7 is shipped with jQuery 1.4.4 and so is not ready for the plugin I need to use, there is a plugin that update jQuery and jQuery UI but where is the fun?
The procedure is pretty quick:
- Download the jQuery version you need from from the official source.
- Place the jQuery version you downloaded in your theme js’s folder (like MYTHEME/js/).
- Create/Modify your theme’s
template.phpfile as described below.
Now for the
template.php, you need to use the hook_js_alter to replace the native jQuery:
//We define the path of our new jquery core file
//assuming we are using the minified version 1.8.3
$jquery_path = drupal_get_path('theme','MYTHEME') . '/js/jquery-1.8.3.min.js';
//We duplicate the important information from the Drupal one
//..and we update the information that we care about
//Then we remove the Drupal core version
After we clear the cache we will have the new jQuery version.
Keep in mind that changing the jQuery version may create some incompatibility issues with the other Drupal core scripts.