1 Comment

How to load more than one version of jQuery?

Well it is not recommended to use multiple version of jquery. One must use only the latest version of jquery. Reason of using latest version is
New added features, bug fixes old version and at last performance.
However, it’s not always possible to upgrade as soon as a new version comes out.
New version may not be compatible with your old slider, validation plug-in or any of your jquery plug-in.
This is where jQuery.noConflict() comes in.

jQuery.noConflict() Function

Description: Relinquish jQuery’s control of the $ variable.
this version added in jquery version 1.0 .It takes Boolean as argument.
If called by passing true argument then remove all jQuery variables from the global scope (including jQuery itself).

Using jQuery.noConflict() With other libraries like mootools

Many JavaScript libraries like mootools use $ as a function or variable name, just as jQuery does. In jQuery’s case, $ is just an alias for jQuery, you can work with jQuery without using $.
If your are using another libraries like mootools then there may be a conflict occur. So to remove this conflict jQuery noConflict comes into play

how to use jQuery no Conflict with other libraries
[javascript]
[/javascript]

Using jQuery.noConflict() to load more than one version of jQuery

As you can see in jQuery noConflict if we pass a true argument then it remove all jQuery variables from the global scope (including jQuery itself)

Using jQuery.noConflict() to load more than one versions of jQuery is simple. Load your plugin in correct order .i.e. if your validation plug-in works with jQuery 1.4 version then load jQuery 1.4 first and then load your plug-in.

And now if you are your slider does not work with old version of jQuery load new version of jQuery. And load your slider plug-in. Now inside the code your need to call jQuery.noConflict with argument true.
Example of using multiple version of jQuery .
[javascript]

My content

[/javascript]
Now you can use either version of jQuery by using the two new variables we’ve created:
Well it is not recommended to use multiple version of jQuery .But in certain condition if can’t change the already existed jQuery in header and you need to integrate a new feature in site and works with other version of jQuery then this tricks works pretty well. It helped me hope it will help you too. Thanks.

Read more: http://buffernow.com/load-more-than-one-version-of-jquery/#ixzz3Wbca4jUG

One comment on “How to load more than one version of jQuery?

Leave a comment