开发者

JQuery version does matter?

开发者 https://www.devze.com 2023-02-18 18:13 出处:网络
I have used JQuery api different version in my project like i used 1.4.2, 1.4.4, 1.5 etc. One of my colleague asked to use same version in on开发者_如何学Pythone project and he says if you use differ

I have used JQuery api different version in my project like i used 1.4.2, 1.4.4, 1.5 etc.

One of my colleague asked to use same version in on开发者_如何学Pythone project and he says if you use different version of API it'll contradict within your project whether i don't understand of his mean. What you say ?


If you use two different versions of jQuery in your project, but one of them is used on one page and the other is used on a different page, there's no conflict at all. It's not a good idea from a working practices perspective, but there's no conflict.

If you include two different versions of jQuery on the same page, barring your taking special measures, the latter one will win. So for instance:

<script src='jquery-1.4.4.js'></script>
<script src='jquery-1.5.1.js'></script>
<script>
    alert(jQuery.prototype.jquery); // Alerts 1.5.1
</script>

It's actually possible to use two different versions on the same page simultaneously, through creative use of jQuery.noConflict. That came up in a question here last week (see the link for how you do it), because a developer wanted to bundle jQuery with his ASP.Net component, but handle it gracefully if the page on which the component was loaded also included jQuery (and possibly a different version of it).

But for procedural reasons, for debugging, for sanity, if you have control over what ends up on the pages, standardize on one version of the library. If you don't, you're bound to end up wasting time chasing bugs.


If you are using some general method or properties of JQuery, it will not conflict at all. Hovewer, if you use a feature that is included in a latter version, and you included the previous one, the JQuery will not work as supposed.

In conclusion, using the same version is a best practice to do.


its true

just use one version in your project rather than trying multiple version.

because each version release have some set of new function and updates on older function there may be change in existing function which cause problem some time. this is true for all development library, not only for jquery version.


It's always better to use one API or library across one project whether its jQuery or any other library. This way you can be sure not to make an issue regarding library versions, and your potential bugs can be tracked to only one library. Also newer versions of library can fix previous bugs, but can also introduce new one. Using one library at least you know where to be cautious around.

Also you will know which API documentation to read, not to mention documentation hell


Yes, We should avoid to use the multiple version of API in same project.

In special cases you can use. The reason is not using multiple version of API is "UPDATE" of same function/method in newer version of API.


You should read the release notes / change log to make sure anything has changed or not if you're going to use different versions.

0

精彩评论

暂无评论...
验证码 换一张
取 消