How to avoid jquery conflict with other javascript libraries

Avoid jquery conflict with other javascript libraries

Use of .noConflict() method of jQuery

It will revert $ back to its original library.


Additionally, there is another option for you. If you want to make sure that jQuery won't conflict with other javascript libraries - but you want the benefit of a short name, you can do something like i have done below:

You can define anything as your own alternate name (e.g. hello, pakistan, cricket, jq).


Finally, if you don't want to define alternative to the jQuery name (you deadly want to use $ and don't care about using another library's $ method), then you have another solution. This is most frequently used in such case when you still want the benefits of really short jQuery code, but you don't want to cause conflicts with other javascript libraries.

This is probably the perfect solution for most of your code, considering that there'll be less code that you'll have to change for getting complete compatibility of jquery with other javascript libraries. So these are the different techniques to avoid jquery conflict with other javascript libraries.

0 comments:

Post a Comment