jQuery 3 Released

jQuery, the widely-used JavaScript library, hit a milestone and is now on version 3.

In an announcement on the jQuery Blog, Timmy Willison explains the changes.

  • jQuery.Deferred is now Promises/A+ compatible
  • Added .catch() to Deferreds
  • Error cases don’t silently fail
  • Removed deprecated event aliases
  • Animations now use requestAnimationFrame
  • Massive speedups for some jQuery custom selectors

On top of the plethora of changes they’ve added a slim build, which excludes ajax, effects and deprecated code and comes in at about a fifth smaller.

Although jQuery is useful, some would call it overkill for certain tasks. jQuery is a 30k dependency, which isn’t a lot for a one-time load on a big website. If you’re using the Google CDN, there’s a chance it’ll already have been cached. Still, 30k is 30k, and that might be doubling the size of your web page, and that’s not even taking into account the performance hit of parsing jQuery.

The website You Might Not Need jQuery was built by contributors from HubSpot, and does a good job of providing vanilla JavaScript examples against jQuery ones. The issue here is that the jQuery versions are more elegant, and there’s no documented way of finding elements (it assumes you have done already).

Chris Ferdinandi has an article about ditching jQuery for vanilla JavaScript. It’s a great read and explains the querySelector API in native JavaScript, which replaces the need for jQuery’s selector functionality and is available in most modern browsers.

I haven’t had the need to build a website with JavaScript yet, but I’ve kept Chris’s document bookmarked for when I do. Hopefully I can get around without jQuery.

At the end of the day it’s important that most applications gracefully degrade. If the client can’t use JavaScript, we shouldn’t exclude them. We should at least try to provide the same functionality server side, if we can.