即将到来的jQuery 3.0会有什么?
Initially released almost eight years ago, it seems unlikely that jQuery needs an introduction to web developers. It is by far the most ubiquitous JavaScript framework on the web and at present, more than 60% of web applications use some functionality of the framework.
The Internet is constantly changing and in order to keep up, jQuery is evolving too. In this post we’re going to look in a little more detail at what’s coming down the line in version 3.0.
What’s so appealing about jQuery?
jQuery is a cross-platform JavaScript library designed to simplify client-side scripting. It’s a free, open-source software and registered under the MIT license. Some common features of jQuery that developers appreciate are that it allows them to navigate through a document, select DOM elements, use animations, handle events and use Ajax for asynchronous calls to services. jQuery also allows developers to create plug-ins on top of the library. The platform’s rich plug-in ecosystem provides a plethora of possibilities for building powerful and dynamic web pages and applications.
jQuery comes in two versions:
- A backwards browser compatible version, currently at version 1.11.1
- A more modern version, which no longer supports older browsers like IE8. Currently at version 2.1.1
Since the start of the development of jQuery in the mid-2000s, browser compatibility has been as important as API compatibility - the reason why two versions were shipped.
Semantic Versioning and jQuery 3.0
The newest release of jQuery will follow the best practices of what is called "semantic versioning" or "semver". These best practices state that the version numbers must follow the major.minor.patch pattern. A new major number indicates that there is a breaking change in the API and developers need to be aware that this could break their code.
In previous versions, the jQuery team indicated browser support using the version number. The 1.x versions were compatible with older browsers like IE6, 7 and 8 but the 2.x versions only supported recent browsers. However, the two versions were actually compatible API-wise with one another.
The next release of jQuery, version 3.0, will start from a clean sheet, although there will still be two versions:
- jQuery Compat 3.0: the browser compatible version. This library will support all browsers and most versions. This will lead to a larger file size and a potential lower performance.
- jQuery 3.0: this version will only support the most common browsers with the current version and the previous versions. This library will be a lot slimmer and will perform faster.
A big jump in version numbering will not lead to big migration issues however - developers will be relieved to hear that the majority of the current jQuery code will still work. With the version change the jQuery development team will meet the semantic versioning standards, so the changed or deprecated methods will be detected by a new version of the jQuery Migrate plugin.
The new release of jQuery is not a major rework of the API like that announced by Angular for example. The design doesn't actually need a lot of changes but simply some optimisations. The two principal changes we already know about are Promise/A+ compatibility for Deferred Implementation and the return of requestAnimationFrame for animations in order to improve performance and battery life. The most important aspect of the new release will be the streamlining of versioning.
The key points to remember are:
- If you need support for the widest variety of browsers, you’ll need the jQuery 3.0 Compat package.
- If your web application is built for the leading edge browsers, or is an HTML based application contained in a webview (like PhoneGap or Cordova) where you know which browser engines are in use, the jQuery 3.0 package will be most suitable for you.
jQuery 3.0 - here to stay
jQuery are offering an upgrade to their coding language which will flexibly allow users to incorporate previous versions, but which is also looking forward and responding to changes in web design. Here at Infragistics, we’re looking forward to seeing how these changes will be adopted by the development community.
来自:http://www.infragistics.com/community/blogs/marketing/archive/2015/01/20/what-39-s-coming-in-jquery-3-0.aspx