Multiple Jquery versions in your Web Application

By: mendesdomnic

October 18, 2010 11:00 am





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:

<script type='text/javascript' src='js/jquery_1.3.2.js'></script>
<script type='text/javascript' src='js/ABC.js'></script>   
<script type='text/javascript'>  
   var $jq132 = jQuery.noConflict();  
<script type='text/javascript' src='js/jquery_1.4.2.js'></script></code>

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.

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.

Tags: ,
Categories: Enterprise Linux, Technical Solutions

Disclaimer: As with everything else in the SUSE Blog, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.