jQuery 1.7 is ready to load! You can download from jQuery CDN:
code.jquery.com/jquery-1.7.jscode.jquery.com/jquery-1.7.min.jsAlso, this release will be ready for download from Google and Microsoft CDNs in a day or two.
The jQuery team thanks everyone who took part in testing and searching for bugs in beta versions and believes in the strength and stability of the release. And he asks anyone who finds any bugs to report on them to a
bug tracker and, if possible, back up with tests for playback on
jsFiddle for faster problem analysis.
What's New in Version 1.7
A short list of innovations can be quickly obtained by reviewing the
description of the API with the tag 1.7 , and below will be a description of the major innovations of version 1.7 and some things that have not yet been included in the API documentation.
')
New event API: .on () and .off ()
The new
.on () and .off () API makes it universal and more convenient to bind to events in the document.
$(elements).on( events [, selector] [, data] , handler ); $(elements).off( [ events ] [, selector] [, handler] );
When
selector
is specified, the
.on()
method works the same way as
.delegate()
binds event handlers, filtering elements by selector. If the
selector
not specified or is
null
, then the call works like a normal
.bind()
. There is some ambiguity: if the
data
argument is a string, you must explicitly pass the
selector
argument as a string or
null
so that
data
not mistaken for a selector. When transferring an object as
data
, you do not need to worry about specifying a selector.
All existing types of event bindings (and the corresponding method of decoupling from events) are available in version 1.7, but it is recommended to use
.on()
for new projects, where version 1.7 or
.on()
guaranteed to be used. Below are small examples that demonstrate similar bindings to events using the old and new APIs:
$('a').bind('click', myHandler); $('a').on('click', myHandler); $('form').bind('submit', { val: 42 }, fn); $('form').on('submit', { val: 42 }, fn); $(window).unbind('scroll.myPlugin'); $(window).off('scroll.myPlugin'); $('.comment').delegate('a.add', 'click', addNew); $('.comment').on('click', 'a.add', addNew); $('.dialog').undelegate('a', 'click.myDlg'); $('.dialog').off('click.myDlg', 'a'); $('a').live('click', fn); $(document).on('click', 'a', fn); $('a').die('click'); $(document).off('click', 'a');
Improved delegated event performance
Delegation of events (event delegation) is becoming increasingly important with increasing size and complexity of pages. Frameworks such as Backbone and Sproutcore widely use event delegation. With this in mind, event handling in jQuery 1.7 was reworked to speed up the event handling process, especially for the most common cases.
To optimize the code for common types of selectors, the jQuery team looked at a slice with Google Codesearch. Nearly two thirds of all selectors used in
.live()
and
.delegate()
are
tag#id.class
, where one or more tags, id or classes are used. In optimizing the parsing of these simple selectors, the jQuery team has achieved such success that it was able to bypass even the time of the native
matchesSelector
browsers during event processing. The Sizzle engine is still used to parse more complex selectors.
The end result is almost double the acceleration compared to version 1.6.4:

Improved HTML 5 support in IE 6/7/8
Anyone who has tried to use new tags from HTML5, such as
<section>
, is guaranteed to have problems not only with the fact that IE 6/7/8 does not understand these tags, but also completely remove them from the document. JQuery 1.7 has built-in support for HTML5 tags for older IE in methods such as
.html()
. This mechanism is implemented at the same level as earlier
innerShiv .
You still need to enable HTML5Shiv in the head
section of the document to support HTML5 tags in older IE. For details, see
The Story of the HTML5 Shiv .
Intuitive work of switching animations
In previous versions of jQuery, switching animations, such as
.slideToggle()
or
.fadeToggle()
, did not work correctly if several animations were run sequentially and the previous one was interrupted by the
.stop()
method. This was fixed in version 1.7, the initial values are now remembered before the animation starts, and values are reset if the animation switching was interrupted prematurely.
Asynchronous Module Definition (AMD)
Now jQuery
supports asynchronous module definition -
AMD API . This does not mean that jQuery is a script loader; jQuery only uses an AMD-compatible module definition model, supported for example by RequireJS or curl.js, so jQuery can be connected dynamically with such a loader, and the
ready
event is also controlled by it. Now AMD-compatible bootloaders can connect an unmodified version of jQuery from a CDN (for example, from Google or Microsoft). Special thanks go to James Burke (@jrburke) for providing the patch and tests and waiting for their build to be included.
jQuery.Deferred
The
jQuery.Deferred object
has been extended with new progress handlers and notification methods calling these handlers. This allows you to asynchronously notify listeners about the progress of execution without completing or canceling the request. Additionally, a
state()
method has appeared, which returns the state of a Deferred object, which is primarily useful for debugging.
Now, Deferreds are implemented through the use of new functionality -
jQuery.Callbacks , a generic call queue function or a series of callbacks. This new functionality may be of interest to plugin writers, although Deferreds and the event system provide a higher level of similar functionality.
jQuery.isNumeric ()
Inside jQuery, several situations were found when you need to know whether the argument is a number or can be successfully converted to a number. And it was decided to write and document the
jQuery.isNumeric () method as a useful utility. Pass any argument inside it and get
true
or
false
as the result.
Remote functionality
event.layerX and event.layerY: in version 1.7 these non-standard properties have been removed. Although they previously did not interfere with anyone, Chrome 16 displays many warnings in the console. Therefore, it was decided to abandon them and delete. Where these properties are still supported, they will be accessible via
event.originalEvent.layerX
and
event.originalEvent.layerY
.
jQuery.isNaN (): this undocumented utility has also been removed. It had the name of the built-in JavaScript function, but semantically did not correspond to it. The new
jQuery.isNumeric()
function allows you to do the same. Although the
jQuery.isNaN()
function
jQuery.isNaN()
been undocumented, some projects on Github have used it. The jQuery team contacted them and warned about the problem and possible solutions.
jQuery.event.proxy (): this undocumented and obsolete method has been removed. Instead, use the jQuery.proxy documented method.
Other thanks and change log with a list of all bug fixes can be found at the end of the original article blog.jquery.com/2011/11/03/jquery-1-7-released