jQuery 3.1.1 Released!

Posted on by

jQuery 3.1.1 is now available!

This release includes some bug fixes and improvements. As with all patch version releases, there are no new features or intended compatibility issues (if upgrading from jQuery 3.0+) in this release.

We fixed a selector issue with disabled options, exposed jQuery.noConflict even when jQuery is loaded with AMD, and fixed some issues concerning whitespace. We also fixed an issue with the map file that will help when using CDN copies during debugging.

If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

GitHub changelog: Issues fixed in 3.1.1 | All changes

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.1.1.js

https://code.jquery.com/jquery-3.1.1.min.js

You can also get this release from npm:

npm install jquery@3.1.1

Slim build

Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’ve released a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code. The size of jQuery is very rarely a load performance concern these days, but the slim build is about 6k gzipped bytes smaller than the regular version – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.1.1.slim.js
https://code.jquery.com/jquery-3.1.1.slim.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.

Thanks

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Oleg Gaidarenko, Michał Gołębiowski, Richard Gibson, Alexander Lisianoi, Steve Mao, Dave Methvin, and the whole jQuery team.

jQuery 3.1.0 Released – No More Silent Errors

Posted on by

Not so long ago, we released jQuery 3.0. One of the major features of jQuery 3.0 was a small rewrite of jQuery Deferreds. Specifically, we made them compatible with the Promises/A+ spec. That basically meant that errors had to be silenced and passed as rejection values to rejection handlers (added using deferred.catch()). This had the advantage of preventing Promise handlers from getting blocked up by runtime errors, but the disadvantage of errors being silenced if no rejection handlers were added. While this was the right move for Deferreds, we had also changed jQuery.ready and jQuery.fn.ready to use the new spec-compliant Deferreds under the covers.

Unfortunately, if you were using the usual ways to attach ready handlers (e.g. jQuery(function() {}) and jQuery(document).ready(function() {})), you had no way to add a rejection handler. Plus, it wasn’t obvious that you were in Deferred land. Any runtime exceptions were getting swallowed and lost in space. I think they ended up somewhere near Pluto, which isn’t even a planet anymore! There were workarounds, but this wasn’t acceptable to us.

We immediately set out to fix this, and thus jQuery 3.1.0 was born. No longer will errors be silent! You will see them logged to the console by default. If you’d like to have more control on how these errors are handled, we also added an entry point: jQuery.readyException. In most cases, you won’t need to use it, but any errors that are thrown within a ready handler will get passed to this function should you need it.

jQuery.readyException =
  function(error) {
    // "error" is thrown from
    // any ready handler
  };

The default jQuery.readyException will re-throw the error asynchronously, to avoid stopping execution and log the error to the console. We hope this solves any debugging issues you may have experienced when using jQuery 3.0.

We do not expect this release to have any breaking changes, but if you do encounter bugs in upgrading from the previous version, please let us know.

If you’d like help upgrading from jQuery 1.x or 2.x to jQuery 3.0, please check out the 3.0 Upgrade Guide and the jQuery Migrate 1.4.1 blog post.

3.1.0GitHub changelog

Download

You can include these files directly from the jQuery CDN if you like, or copy them to your own local server.

https://code.jquery.com/jquery-3.1.0.js
https://code.jquery.com/jquery-3.1.0.min.js

Slim build

Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’ve released a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code. The size of jQuery is very rarely a load performance concern these days, but the slim build is about 6k gzipped bytes smaller than the regular version – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.1.0.slim.js
https://code.jquery.com/jquery-3.1.0.slim.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Oleg Gaidarenko, Micha? Go??biowski, and the whole jQuery team.

jQuery 3.0 Final Released!

Posted on by

jQuery 3.0 is now released! This version has been in the works since October 2014. We set out to create a slimmer, faster version of jQuery (with backwards compatibility in mind). We’ve removed all of the old IE workarounds and taken advantage of some of the more modern web APIs where it made sense. It is a continuation of the 2.x branch, but with a few breaking changes that we felt were long overdue. While the 1.12 and 2.2 branches will continue to receive critical support patches for a time, they will not get any new features or major revisions. jQuery 3.0 is the future of jQuery. If you need IE6-8 support, you can continue to use the latest 1.12 release.

Despite the 3.0 version number, we anticipate that these releases shouldn’t be too much trouble when it comes to upgrading existing code. Yes, there are a few “breaking changes” that justified the major version bump, but we’re hopeful the breakage doesn’t actually affect that many people.

To assist with upgrading, we have a brand new 3.0 Upgrade Guide. And the jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code. Your feedback on the changes will help us greatly, so please try it out on your existing code and plugins!

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.0.0.js

https://code.jquery.com/jquery-3.0.0.min.js

You can also get the release from npm:

npm install jquery@3.0.0

In addition, we’ve got the release for jQuery Migrate 3.0. We highly recommend using this to address any issues with breaking changes in jQuery 3.0. You can get those files here:

https://code.jquery.com/jquery-migrate-3.0.0.js

https://code.jquery.com/jquery-migrate-3.0.0.min.js

npm install jquery-migrate@3.0.0

For more information about upgrading your jQuery 1.x and 2.x pages to jQuery 3.0 with the help of jQuery Migrate, see the jQuery Migrate 1.4.1 blog post.

Slim build

Finally, we’ve added something new to this release. Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’re releasing a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code. The size of jQuery is very rarely a load performance concern these days, but the slim build is about 6k gzipped bytes smaller than the regular version – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.0.0.slim.js

https://code.jquery.com/jquery-3.0.0.slim.min.js

This build was created with our custom build API, which allows you to exclude or include any modules you like. For more information, have a look at the jQuery README.
 

Compatibility with jQuery UI and jQuery Mobile

While most things will work, there are a few issues that jQuery UI and jQuery Mobile will be addressing in upcoming releases. If you find an issue, keep in mind that it may already be addressed upstream and using the jQuery Migrate 3.0 plugin should fix it. Expect releases soon.

 

Major changes

Below are just the highlights of the major new features, improvements, and bug fixes in these releases, you can dig into more detail on the 3.0 Upgrade Guide. A complete list of issues fixed is available on our GitHub bug tracker. If you read the blog post for 3.0.0-rc1, the below features are the same.

jQuery.Deferred is now Promises/A+ compatible

jQuery.Deferred objects have been updated for compatibility with Promises/A+ and ES2015 Promises, verified with the Promises/A+ Compliance Test Suite. This meant we needed some major changes to the .then() method. Legacy behavior can be restored by replacing any use of .then() with the now-deprecated .pipe() method (which has an identical signature).

  1. An exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution. Any deferreds relying on the resolution of the deferred that threw an exception would never have resolved.

  2. Example: uncaught exceptions vs. rejection values

    
    var deferred = jQuery.Deferred();
    deferred.then(function() {
      console.log("first callback");
      throw new Error("error in callback");
    })
    .then(function() {
      console.log("second callback");
    }, function(err) {
      console.log("rejection callback", err instanceof Error);
    });
    deferred.resolve();
    

    Previously, “first callback” was logged and the error was thrown. All execution was stopped. Neither “second callback” nor “rejection callback” would have been logged. The new, standards-compliant behavior is that you’ll now see “rejection callback” and true logged. err is the rejection value from the first callback.


  3. The resolution state of a Deferred created by .then() is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfillment values. Previously, returns from rejection handlers became rejection values.

  4. Example: returns from rejection callbacks

    
    var deferred = jQuery.Deferred();
    deferred.then(null, function(value) {
      console.log("rejection callback 1", value);
      return "value2";
    })
    .then(function(value) {
      console.log("success callback 2", value);
      throw new Error("exception value");
    }, function(value) {
      console.log("rejection callback 2", value);
    })
    .then(null, function(value) {
      console.log("rejection callback 3", value);
    });
    deferred.reject("value1");
    

    Previously, this would log “rejection callback 1 value1”, “rejection callback 2 value2”, and “rejection callback 3 undefined”.

    The new, standards-compliant behavior is that this will log “rejection callback 1 value1”, “success callback 2 value2″, and “rejection callback 3 [object Error]”.


  5. Callbacks are always invoked asynchronously, even if a Deferred has already been resolved. Previously, these callbacks were executed synchronously upon binding.

  6. Example: async vs sync

    
    var deferred = jQuery.Deferred();
    deferred.resolve();
    deferred.then(function() {
      console.log("success callback");
    });
    console.log("after binding");
    

    Previously, this would log “success callback” then “after binding”. Now, it will log “after binding” and then “success callback”.


Important: while caught exceptions had advantages for in-browser debugging, it is far more declarative (i.e. explicit) to handle them with rejection callbacks. Keep in mind that this places the responsibility on you to always add at least one rejection callback when working with promises. Otherwise, some errors might go unnoticed.

We’ve built a plugin to help in debugging Promises/A+ compatible Deferreds. If you are not seeing enough information about an error on the console to determine its source, check out the jQuery Deferred Reporter Plugin.

jQuery.when has also been updated to accept any thenable object, which includes native Promise objects.

https://github.com/jquery/jquery/issues/1722
https://github.com/jquery/jquery/issues/2102

Added .catch() to Deferreds

The catch() method was added to promise objects as an alias for .then(null, fn).

https://github.com/jquery/jquery/issues/2102

Error cases don’t silently fail

Perhaps in a profound moment you’ve wondered, “What is the offset of a window?” Then you probably realized that is a crazy question – how can a window even have an offset?

In the past, jQuery has sometimes tried to make cases like this return something rather than having them throw errors. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 } With jQuery 3.0, such cases will throw errors so that crazy requests aren’t silently ignored. Please try out this release and see if there is any code out there depending on jQuery to mask problems with invalid inputs.

https://github.com/jquery/jquery/issues/1784

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

https://github.com/jquery/jquery/issues/2286

Animations now use requestAnimationFrame

On platforms that support the requestAnimationFrame API, which is pretty much everywhere but IE9 and Android<4.4, jQuery will now use that API when performing animations. This should result in animations that are smoother and use less CPU time – and save battery as well on mobile devices.

jQuery tried using requestAnimationFrame a few years back but there were serious compatibility issues with existing code so we had to back it out. We think we’ve beaten most of those issues by suspending animations while a browser tab is out of view. Still, any code that depends on animations to always run in nearly real-time is making an unrealistic assumption.

Massive speedups for some jQuery custom selectors

Thanks to some detective work by Paul Irish at Google, we identified some cases where we could skip a bunch of extra work when custom selectors like :visible are used many times in the same document. That particular case is up to 17 times faster now!

Keep in mind that even with this improvement, selectors like :visible and :hidden can be expensive because they depend on the browser to determine whether elements are actually displaying on the page. That may require, in the worst case, a complete recalculation of CSS styles and page layout! While we don’t discourage their use in most cases, we recommend testing your pages to determine if these selectors are causing performance issues.

This change actually made it into 1.12/2.2, but we wanted to reiterate it for jQuery 3.0.

https://github.com/jquery/jquery/issues/2042

As mentioned above, the Upgrade Guide is now available for anyone ready to try out this release. Aside from being helpful in upgrading, it also lists more of the notable changes.

 

Thanks

Thank you to everyone who helped with this release through code contributions, issue reports, and more, including but not limited to Jason Bedard, Fredrik Blomqvist, Leonardo Braga, Ralin Chimev, Jon Dufresne, Oleg Gaidarenko, Richard Gibson, Michał Gołębiowski, Scott González, Zack Hall, Alexander K, Martijn W. van der Lee, Alexander Lisianoi, Steve Mao, Dave Methvin, Jha Naman, Jae Sung Park, Todor Prikumov, William Robinet, Felipe Sateler, Damian Senn, Josh Soref, Jun Sun, Christophe Tafani-Dereeper, Vitaliy Terziev, Joe Trumbull, Bernhard M. Wiedemann, Devin Wilson, and Henry Wong.

 

Changelog

Ajax

  • Golf away 21 bytes (eaa3e9f)
  • Preserve URL hash on requests (#1732, e077ffb)
  • Execute jQuery#load callback with correct context (#3035, 5d20a3c)
  • Ensure ajaxSettings.traditional is still honored (#3023, df2051c)
  • Remove unnecessary use of jQuery.trim (0bd98b1)

Attributes

  • Avoid infinite recursion on non-lowercase attribute getters (#3133, e06fda6)
  • Add a support comment & fix a link @ tabIndex hook (9cb89bf)
  • Strip/collapse whitespace for set values on selects (#2978, 7052698)
  • Remove redundant parent check (b43a368)
  • Fix setting selected on an option in IE<=11 (#2732, 780cac8)

CSS

  • Don’t workaround the IE 11 iframe-in-fullscreen sizing issues (#3041, ff1a082)
  • Toggle detached elements as visible unless they have display: none (#2863, 755e7cc)
  • Make sure elem.ownerDocument.defaultView is not null (#2866, 35c3148)
  • Add animation-iteration-count to cssNumber (#2792, df822ca)
  • Restore cascade-override behavior in .show (#2654, #2308, dba93f7)
  • Stop Firefox from treating disconnected elements as cascade-hidden (#2833, fe05cf3)

Core

Deferred

  • Separate the two paths in jQuery.when (#3029, 356a3bc)
  • Provide explicit undefined context for jQuery.when raw casts (#3082, 7f1e593)
  • Remove default callback context (#3060, 7608437)
  • Warn on exceptions that are likely programming errors (#2736, 36a7cf9)
  • Propagate progress correctly from unwrapped promises (#3062, d5dae25)
  • Make jQuery.when synchronous when possible (#3100, de71e97)
  • Remove undocumented progress notifications in $.when (#2710, bdf1b8f)
  • Give better stack diagnostics on exceptions (07c11c0)

Dimensions

  • Add tests for negative borders & paddings (f00dd0f)

Docs

  • Fix various spelling errors (aae4411)
  • Update support comments related to IE (693f1b5)
  • Fix an incorrect comment in the attributes module (5430c54)
  • Updated links to https where they are supported. (b0b280c)
  • Update support comments to follow the new syntax (6072d15)
  • Use https where possible (1de8346)
  • Use HTTPS URLs for jsfiddle & jsbin (63a303f)
  • Add FAQ to reduce noise in issues (dbdc4b7)
  • Add a note about loading source with AMD (#2714, e0c25ab)
  • Add note about code organization with AMD (#2750, dbc4608)
  • Reference new feature guidelines and API tenets (#2320, 6054139)

Effects

Event

  • Allow constructing a jQuery.Event without a target (#3139, 2df590e)
  • Add touch event properties, eliminates need for a plugin (#3104, f595808)
  • Add the most commonly used pointer event properties (7d21f02)
  • Remove fixHooks, propHooks; switch to ES5 getter with addProp (#3103, #1746, e61fccb)
  • Make event dispatch optimizable by JavaScript engines (9f268ca)
  • Evaluate delegate selectors at add time (#3071, 7fd36ea)
  • Cover invalid delegation selector edge cases (e8825a5)
  • Fix chaining .on() with null handlers (#2846, 17f0e26)
  • Remove pageX/pageY fill for event object (#3092, 931f45f)

Events

  • Don’t execute native stop(Immediate)Propagation from simulation (#3111, 94efb79)

Manipulation

Offset

  • Resolve strict mode ClientRect “no setter” exception (3befe59)

Selector

Serialize

  • Treat literal and function-returned null/undefined the same (#3005, 9fdbdd3)
  • Reduce size (91850ec)

Support

Tests

  • Take Safari 9.1 into account (234a2d8)
  • Limit selection to #qunit-fixture in attributes.js (ddb2c06)
  • Set Edge’s expected support for clearCloneStyle to true (28f0329)
  • Fix Deferred tests in Android 5.0’s stock Chrome browser & Yandex.Browser (5c01cb1)
  • Add additional test for jQuery.isPlainObject (728ea2f)
  • Build: update QUnit and fix incorrect test (b97c8d3)
  • Fix manipulation tests in Android 4.4 (0b0d4c6)
  • Remove side-effects of one attributes test (f9ea869)
  • Account for new offset tests (f52fa81)
  • Make iframe tests wait after checking isReady (08d73d7)
  • Refactor testIframe() to make it DRYer and more consistent (e5ffcb0)
  • Weaken sync-assumption from jQuery.when to jQuery.ready.then (f496182)
  • Test element position outside view (#2909, a2f63ff)
  • Make the regex catching Safari 9.0/9.1 more resilient (7f2ebd2)

Traversing

  • .not/.filter consistency with non-elements (#2808, 0e2f8f9)
  • Never let .closest() match positional selectors (#2796, a268f52)
  • Restore jQuery push behavior in .find (#2370, 4d3050b)

jQuery 3.0 Release Candidate…Released!

Posted on by

Welcome to the Release Candidate for jQuery 3.0! This is the same code we expect to release as the final version of jQuery 3.0 (pending any major bugs or regressions). When released, jQuery 3.0 will become the only version of jQuery. The 1.12 and 2.2 branches will continue to receive critical support patches for a while, but will not get any new features or major revisions. Note that jQuery 3.0 will not support IE6-8. If you need IE6-8 support, you can continue to use the latest 1.12 release.

Despite the 3.0 version number, we anticipate that these releases shouldn’t be too much trouble when it comes to upgrading existing code. Yes, there are a few “breaking changes” that justified the major version bump, but we’re hopeful the breakage doesn’t actually affect that many people.

To assist with upgrading, we have a brand new 3.0 Upgrade Guide. And the jQuery Migrate 3.0-rc plugin will help you to identify compatibility issues in your code. Your feedback on the changes will help us greatly, so please try it out on your existing code and plugins!

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.0.0-rc1.js

https://code.jquery.com/jquery-3.0.0-rc1.min.js

You can also get the release candidate from npm:

npm install jquery@3.0.0-rc1

In addition, we’ve got the release candidate for jQuery Migrate 3.0. We highly recommend using this to address any issues with breaking changes in jQuery 3.0. You can get those files here:

https://code.jquery.com/jquery-migrate-3.0.0-rc1.js

https://code.jquery.com/jquery-migrate-3.0.0-rc1.min.js

npm install jquery-migrate@3.0.0-rc1

For more information about upgrading your jQuery 1.x and 2.x pages to jQuery 3.0 with the help of jQuery Migrate, see yesterday’s jQuery Migrate blog post.

 

Major changes

Below are just the highlights of the major new features, improvements, and bug fixes in these releases, you can dig into more detail on the 3.0 Upgrade Guide. A complete list of issues fixed is available on our GitHub bug tracker.

jQuery.Deferred is now Promises/A+ compatible

jQuery.Deferred objects have been updated for compatibility with Promises/A+ and ES2015 Promises, verified with the Promises/A+ Compliance Test Suite. This meant we needed some major changes to the .then() method:

  • An exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution and irreversibly locking both the parent and child Deferred objects.
  • The resolution state of a Deferred created by .then() is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfillment values. Previously, returns from rejection handlers became rejection values.
  • Callbacks are always invoked asynchronously. Previously, they would be called immediately upon binding or resolution, whichever came last.

Consider the following, in which a parent Deferred is rejected and a child callback generates an exception:


var parent = jQuery.Deferred();
var child = parent.then( null, function() {
  return "bar";
});
var callback = function( state ) {
  return function( value ) {
    console.log( state, value );
    throw new Error( "baz" );
  };
};
var grandchildren = [
  child.then( callback( "fulfilled" ), callback( "rejected" ) ),
  child.then( callback( "fulfilled" ), callback( "rejected" ) )
];
parent.reject( "foo" );
console.log( "parent resolved" );

As of jQuery 3.0, this will log “parent resolved” before invoking any callback, each child callback will then log “fulfilled bar”, and the grandchildren will be rejected with Error “baz”. In previous versions, this would log “rejected bar” (the child Deferred having been rejected instead of fulfilled) once and then immediately terminate with uncaught Error “baz” (“parent resolved” not being logged and the grandchildren remaining unresolved).

While caught exceptions had advantages for in-browser debugging, it is far more declarative (i.e. explicit) to handle them with rejection callbacks. Keep in mind that this places the responsibility on you to always add at least one rejection callback when working with promises. Otherwise, any errors will go unnoticed.

Legacy behavior can be recovered by replacing use of .then() with the now-deprecated .pipe() method (which has an identical signature).

We’ve also built a plugin to help in debugging Promises/A+ compatible Deferreds. If you are not seeing enough information about an error on the console to determine its source, check out the jQuery Deferred Reporter Plugin.

jQuery.when has also been updated to accept any thenable object, which includes native Promise objects.

https://github.com/jquery/jquery/issues/1722
https://github.com/jquery/jquery/issues/2102

Added .catch() to Deferreds

The catch() method was added to promise objects as an alias for .then(null, fn).

https://github.com/jquery/jquery/issues/2102

Error cases don’t silently fail

Perhaps in a profound moment you’ve wondered, “What is the offset of a window?” Then you probably realized that is a crazy question – how can a window even have an offset?

In the past, jQuery has sometimes tried to make cases like this return something rather than having them throw errors. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 } With jQuery 3.0, such cases will throw errors so that crazy requests aren’t silently ignored. Please try out this release and see if there is any code out there depending on jQuery to mask problems with invalid inputs.

https://github.com/jquery/jquery/issues/1784

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

https://github.com/jquery/jquery/issues/2286

Animations now use requestAnimationFrame

On platforms that support the requestAnimationFrame API, which is pretty much everywhere but IE9 and Android<4.4, jQuery will now use that API when performing animations. This should result in animations that are smoother and use less CPU time – and save battery as well on mobile devices.

jQuery tried using requestAnimationFrame a few years back but there were serious compatibility issues with existing code so we had to back it out. We think we’ve beaten most of those issues by suspending animations while a browser tab is out of view. Still, any code that depends on animations to always run in nearly real-time is making an unrealistic assumption.

Massive speedups for some jQuery custom selectors

Thanks to some detective work by Paul Irish at Google, we identified some cases where we could skip a bunch of extra work when custom selectors like :visible are used many times in the same document. That particular case is up to 17 times faster now!

Keep in mind that even with this improvement, selectors like :visible and :hidden can be expensive because they depend on the browser to determine whether elements are actually displaying on the page. That may require, in the worst case, a complete recalculation of CSS styles and page layout! While we don’t discourage their use in most cases, we recommend testing your pages to determine if these selectors are causing performance issues.

This change actually made it into 1.12/2.2, but we wanted to reiterate it for jQuery 3.0.

https://github.com/jquery/jquery/issues/2042

As mentioned above, the Upgrade Guide is now available for anyone ready to try out this release. Aside from being helpful in upgrading, it also lists more of the notable changes.

jQuery 1.12.4 and 2.2.4 Released

Posted on by

jQuery 1.12.4 and 2.2.4 have been released! These are small releases with a couple bug fixes. We fixed a sticky issue for those using the AMD source and a “:visible” selector bug in 1.12.3.

If you need any help upgrading, check out the newest release of the jQuery Migrate plugin. Note that jQuery Migrate 1.4.1 is meant to work with these 1.x and 2.x releases, and not jQuery 3.0. jQuery 3.0 has not been released yet – though we will have an RC for you very soon – but another version of Migrate will be released for jQuery 3.0.

We do not expect this release to have any breaking changes, but if you do encounter bugs in upgrading from the previous version, please let us know.

Full changelogs

2.2.4GitHub changelog

1.12.4GitHub changelog

Download

You can include these files directly from the jQuery CDN if you like, or copy them to your own local server. The 1.x branch includes support for IE 6/7/8 and the 2.x branch does not.

https://code.jquery.com/jquery-1.12.4.js
https://code.jquery.com/jquery-1.12.4.min.js

https://code.jquery.com/jquery-2.2.4.js
https://code.jquery.com/jquery-2.2.4.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Oleg Gaidarenko, Michał Gołębiowski, and the whole jQuery team.

jQuery Migrate 1.4.1 released, and the path to jQuery 3.0

Posted on by

Version 1.4.1 of the jQuery Migrate plugin has been released. It has only a few changes but the most important of them fixes a problem with unquoted selectors that seems to be very common in some WordPress themes. In most cases Migrate can automatically fix this problem when it is used with jQuery 1.12.x or 2.2.x, although it may not be able to repair some complex selectors. The good news is that all the cases of unquoted selectors reported in WordPress themes appear to be fixable by this version of Migrate!

You can get this new version at all the old familiar places:

jQuery CDN: https://code.jquery.com/jquery-migrate-1.4.1.js or https://code.jquery.com/jquery-migrate-1.4.1.min.js

npm: Just npm install jquery-migrate@1.4.1 which is listed at https://www.npmjs.com/package/jquery-migrate.

Bower: In your bower.json file, use the following in the dependencies section to copy the CDN file:

 "dependencies": {
    ...
    "jquery-migrate": "https://code.jquery.com/jquery-migrate-1.4.1.js"
  },

As always, we recommend that you use jQuery Migrate as a tool to find and fix issues when upgrading web sites to new versions of jQuery and associated plugins. The non-minified version provides extensive diagnostics on the console. Take advantage of them, we built them for you!

Migrate and jQuery 3.0

jQuery Migrate will be continuing its role of making jQuery upgrades easier. A release candidate for jQuery Migrate 3.0 will be coming soon.

With all the years of accumulated changes, it isn’t possible to have a single version of jQuery Migrate that can support all the changes from jQuery 1.6 (five years ago!) all the way to jQuery 3.0. So, with Migrate 3.0 we recommend this process to upgrade to jQuery 3.0:

  • If you haven’t already, upgrade to the latest 1.x or 2.x version of jQuery, and the latest 1.x version of jQuery Migrate. (As of today that is jQuery 1.12.3 or jQuery 2.2.3, combined with jQuery Migrate 1.4.1.)
  • Fix any problems identified in the Migrate 1.x warning messages you may see on the console.
  • Remove the Migrate 1.x plugin and ensure the page still works properly without it loaded.
  • Upgrade to the latest jQuery 3.x and latest jQuery Migrate 3.x.
  • Fix any problems identified in the Migrate 3.x warning messages you may see on the console.
  • Remove the Migrate 3.x plugin and ensure the page still works properly without it loaded.

Please do use jQuery Migrate 3.0 as you explore this latest release of jQuery, it will greatly simplify finding problems. We want this plugin to be a tool that makes your development life easier. If you find problems you can report them at the issue tracker.

Many thanks to the jQuery core team for their help, and to Github user ekonoval for a very helpful bug report!

jQuery 1.12.3 and 2.2.3 Released

Posted on by

jQuery 1.12.3 and 2.2.3 have been released! These are small releases with a couple bug fixes. There was a minor issue that made the 1.x branch inconsistent with 2.x and a recently-introduced bug in both branches that affected the .load method.

We do not expect this release to have any breaking changes, but if you do encounter bugs in upgrading from the previous version, please let us know.

Full changelogs

2.2.3GitHub changelog

1.12.3GitHub changelog

Download

You can include these files directly from the jQuery CDN if you like, or copy them to your own local server. The 1.x branch includes support for IE 6/7/8 and the 2.x branch does not.

https://code.jquery.com/jquery-1.12.3.js
https://code.jquery.com/jquery-1.12.3.min.js

https://code.jquery.com/jquery-2.2.3.js
https://code.jquery.com/jquery-2.2.3.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Fredrik Blomqvist, Oleg Gaidarenko, Michał Gołębiowski, and the whole jQuery team.

jQuery 1.12.2 and 2.2.2 Released

Posted on by

We’re keeping the releases coming with two new patch releases for the 1.x and 2.x branches. These releases include a few bug fixes, which includes two edge case bugs for jQuery.isPlainObject and a bug when setting the selected property on an option element using the .prop() method in IE 11.

We do not expect this release to have any breaking changes, but if you do encounter bugs in upgrading from the previous version, please let us know.

We’ll have a release candidate of jQuery 3.0 very soon.

Full changelogs

2.2.2GitHub changelog

1.12.2GitHub changelog

Download

You can include these files directly from the jQuery CDN if you like, or copy them to your own local server. The 1.x branch includes support for IE 6/7/8 and the 2.x branch does not.

https://code.jquery.com/jquery-1.12.2.js
https://code.jquery.com/jquery-1.12.2.min.js

https://code.jquery.com/jquery-2.2.2.js
https://code.jquery.com/jquery-2.2.2.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Michał Gołębiowski and Richard Gibson and the whole jQuery team.

jQuery 1.12.1 and 2.2.1 Released

Posted on by

As the jQuery team prepares for a 3.0 final release, we continue to maintain the 1.12 and 2.2 branches. These two patch releases fix a few bugs and improve stability. The most significant bug fix involved a problem with the .position() method, which affected how jQuery UI tooltips were positioned in Internet Explorer.

We do not expect this release to have any breaking changes, but if you do encounter bugs in upgrading from the previous version, please let us know.

Download

You can include these files directly from the jQuery CDN if you like, or copy them to your own local server. The 1.x branch includes support for IE 6/7/8 and the 2.x branch does not.

https://code.jquery.com/jquery-1.12.1.js
https://code.jquery.com/jquery-1.12.1.min.js

https://code.jquery.com/jquery-2.2.1.js
https://code.jquery.com/jquery-2.2.1.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.

Full changelogs

2.2.1GitHub changelog

1.12.1GitHub changelog

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Oleg Gaidarenko, Michał Gołębiowski, Zack Hall, Todor Prikumov, and Devin Wilson.

jQuery 3.0 Beta Released

Posted on by

The time has come. On this day, the 10th anniversary of jQuery, jQuery 3.0 has reached beta status. Last week, we announced the last minor releases to the 1.x and 2.x branches. Those branches will continue to receive patches for a limited time (i.e. only major regressions or bugs); jQuery 3.0 is the future. If you need IE6-8 support, you can continue to use the latest 1.12 release.

The Death of jQuery Compat

only-one

If you read the jQuery 3.0 alpha blog post, you might remember that we announced something we called “jQuery Compat”. You can forget that. On January 12, Microsoft dropped support for IE8, IE9, and IE10. We’re not going to go that far just yet, but we are dropping support for IE8. And with IE8, so goes jQuery Compat, gone before we even released a final version. There will only be one jQuery from now on!

Despite the 3.0 version number, we anticipate that these releases shouldn’t be too much trouble when it comes to upgrading existing code. Yes, there are a few “breaking changes” that justified the major version bump, but we’re hopeful the breakage doesn’t actually affect that many people. The jQuery Migrate 3.0 plugin, when released, will help you to identify compatibility issues in your code as well. Your feedback on the changes will help us greatly, so please try it out on your existing code and plugins!

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.0.0-beta1.js

https://code.jquery.com/jquery-3.0.0-beta1.min.js

You can also get the beta version from npm:

npm install jquery@3.0.0-beta1

 

Major changes

Below are just the highlights of the major new features, improvements, and bug fixes in these releases. A complete list of changes is available on our GitHub bug tracker.

.show() and .hide() methods

In jQuery 3.0 alpha, we experimented with the idea of treating these methods like an inline-display-none-remover (.show()) and inline-display-none-adder (.hide()). This had the advantage of simplifying these methods greatly and improving performance (it required much fewer calculations). However, this proved to be problematic for our users. Removing inline display:none did not always show the element (if the element was hidden from the stylesheet, for example), and that is far too common. We realized we couldn’t provide a simple way for jQuery plugins, especially, to ensure that an element was shown.

We’ve since reverted that change, and the changes that we’ve kept for the show and hide methods should have much less of an impact on your code. In fact, even with the reversion, we’ve greatly improved performance for the case of hiding many elements.

Special case with `.data()` names

We have updated our .data() implementation to closer match the HTML5 dataset specification. All keys are now converted from kebab-case to camelCase, regardless of access method, and digits no longer participate in the conversion. For example, we will no longer differentiate between “foo-bar” and “fooBar”, but will differentiate between “foo-42” and “foo42”. These changes will mainly come into play when retrieving all data by calling .data() with no arguments, or when trying to access the data using a converted key (.data(“foo42”)) instead of the original (.data(“foo-42”)).

https://github.com/jquery/jquery/issues/1751

jQuery.Deferred is now Promises/A+ compatible

jQuery.Deferred objects have been updated for compatibility with Promises/A+ and ES2015 Promises, verified with the Promises/A+ Compliance Test Suite. This meant we need some major changes to the .then() method:

  • An exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution and irreversibly locking both the parent and child Deferred objects.
  • The resolution state of a Deferred created by .then() is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfillment values. Previously, returns from rejection handlers became rejection values.
  • Callbacks are always invoked asynchronously. Previously, they would be called immediately upon binding or resolution, whichever came last.
  • Progress callbacks can no longer resolve Deferred objects to which they are bound.

Consider the following, in which a parent Deferred is rejected and a child callback generates an exception:


var parent = jQuery.Deferred();
var child = parent.then( null, function() {
  return "bar";
});
var callback = function( state ) {
  return function( value ) {
    console.log( state, value );
    throw new Error( "baz" );
  };
};
var grandchildren = [
  child.then( callback( "fulfilled" ), callback( "rejected" ) ),
  child.then( callback( "fulfilled" ), callback( "rejected" ) )
];
parent.reject( "foo" );
console.log( "parent resolved" );

As of jQuery 3.0, this will log “parent resolved” before invoking any callback, each child callback will then log “fulfilled bar”, and the grandchildren will be rejected with Error “baz”. In previous versions, this would log “rejected bar” (the child Deferred having been rejected instead of fulfilled) once and then immediately terminate with uncaught Error “baz” (“parent resolved” not being logged and the grandchildren remaining unresolved).

While caught exceptions had advantages for in-browser debugging, it is far more declarative (i.e. explicit) to handle them with rejection callbacks. Keep in mind that this places the responsibility on you to always add at least one rejection callback when working with promises. Otherwise, any errors will go unnoticed.

Legacy behavior can be recovered by replacing use of .then() with the now-deprecated .pipe() method (which has an identical signature).

We’ve also built a plugin to help make debugging Promises/A+ compatible Deferreds. If you figure out that there’s some phantom error getting eaten, check out the jQuery Deferred Reporter Plugin.

jQuery.when has also been updated to accept any thenable object, which includes native Promise objects.

https://github.com/jquery/jquery/issues/1722
https://github.com/jquery/jquery/issues/2102

Added .catch() to Deferreds

The catch() method was added to promise objects as an alias for .then(null, fn).

https://github.com/jquery/jquery/issues/2102

Removed special-case Deferred methods in jQuery.ajax

jqXHR object is a Promise, but also has extra methods. As users increasingly embrace the Promise pattern for asynchronous work like AJAX, the idea of having special cases with duplicate method names for the Promise returned by jQuery.ajax is an increasingly bad idea. So, these deprecated names have been removed. Instead of the special-case success, error, complete use the corresponding done, fail, always methods.

Note that this does not have any impact at all on the success, error, complete callbacks of the same name, which continue to exist and are not deprecated. This only affects the Promise methods! It also does not remove or deprecate the abort method.

https://github.com/jquery/jquery/issues/2084

Error cases don’t silently fail

Perhaps in a profound moment you’ve wondered, “What is the offset of a window?” Then you probably realized that is a crazy question – how can a window even have an offset?

In the past, jQuery has sometimes tried to make cases like this return something rather than having them throw errors. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 } With this beta of jQuery 3.0 we’re experimenting with the idea of having such cases throw errors so that crazy requests aren’t silently ignored. Please try the beta and see if there is any code out there depending on jQuery to mask problems with invalid inputs.

https://github.com/jquery/jquery/issues/1784

.width(), .height(), .css(“width”), and .css(“height”) to return decimal values (whenever the browser does)

Previously, jQuery rounded values when retrieving width and height. Some browsers return subpixel values – such as IE and Firefox – and sometimes users need this precision when relying on these values for layout. We don’t expect this change to have a big impact on your code, but let us know if it does.

https://github.com/jquery/jquery/issues/1724

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

https://github.com/jquery/jquery/issues/2286

Animations now use requestAnimationFrame

On platforms that support the requestAnimationFrame API, which is pretty much everywhere but IE9 and Android<4.4, jQuery will now use that API when performing animations. This should result in animations that are smoother and use less CPU time – and save battery as well on mobile devices.

jQuery tried using requestAnimationFrame a few years back but there were serious compatibility issues with existing code so we had to back it out. We think we’ve beaten most of those issues by suspending animations while a browser tab is out of view. Still, any code that depends on animations to always run in nearly real-time is making an unrealistic assumption.

.unwrap( selector )

Before jQuery 3.0, the .unwrap() method did not take any arguments. The selector parameter offers a way to be specific about which wrappers to remove.

https://github.com/jquery/jquery/issues/1744

jQuery.fn.domManip no longer accessible

jQuery.dir, jQuery.sibling, jQuery.buildFragment, jQuery.access, and jQuery.swap were all privatized in jQuery 1.12 and 2.2. These methods, along with jQuery.fn.domManip, were always intended for internal use only and were never documented. We are finally making them private to avoid confusion.

https://github.com/jquery/jquery/pull/2182
https://github.com/jquery/jquery/issues/2224
https://github.com/jquery/jquery/issues/2225

Massive speedups for some jQuery custom selectors

Thanks to some detective work by Paul Irish at Google, we identified some cases where we could skip a bunch of extra work when custom selectors like :visible are used many times in the same document. That particular case is up to 17 times faster now!

Keep in mind that even with this improvement, selectors like :visible and :hidden can be expensive because they depend on the browser to determine whether elements are actually displaying on the page. That may require, in the worst case, a complete recalculation of CSS styles and page layout! While we don’t discourage their use in most cases, we recommend testing your pages to determine if these selectors are causing performance issues.

This change actually made it into 1.12/2.2, but we wanted to reiterate it for jQuery 3.0.

https://github.com/jquery/jquery/issues/2042