Multiple Jquery versions in your Web Application
As any software Jquery has evolved and has various releases available. You may have used Jquery plugins available for a feature required in your web application. There can be a scenario where you need to use plugins which are supported by different jquery versions. This tip explains how to go about using multiple versions of jquery.
You have upgraded to Jquery 1.4.2 due to new features required for your Web application. However you have a plugin ABC that works in Jquery version 1.3.2. You need to get the ABC plugin working.
You can continue using the ABC plugin by including both versions of Jquery in your Web Application. Follow the steps below:
Step 1. Load the Jquery 1.3.2 library
Step 2. Load all plugins that are supported only by Jquery 1.3.2
Step 3. Run the noConflict command for the included Jquery. $jq132 = jQuery.noConflict(true);
Step 4. Include the Jquery 1.4.2 library
Step 5. Include all plugins required and supported by Jquery 1.4.2
Step 5. Now you can used the old version of Jquery using $jq132 and new version using $
Below is code snippet:
To invoke the old code for showing hiding a div with id “container”
To invoke the new code for showing hiding a div with id “container”
Make sure you include the code only in the modules where you intend to use the plugin ABC. It may be just one page that requires the plugin.
That’s all guys we are now using two versions of Jquery in our Web application.