What’s New in jQuery 1.8

Craig Buckler
Craig Buckler

It’s been nine months since jQuery 1.7 was released so here we are with a shiny new version to help you write less code in a shorter time while retaining great cross-browser compatibility (for now). Let’s look at the main new features and updates…

More Sizzle

jQuery’s Sizzle selector engine has been optimized for performance and efficiency. It relies on the native querySelectorAll method when it’s available, but even that has implementation differences between browsers. jQuery 1.8 papers over the cracks and still provides coded fallbacks for IE6 and 7.

Automatic CSS Prefixing

When you use a CSS property in methods such as .css() or .animate(), jQuery 1.8 will automatically add any required prefixes. Therefore, you can apply a single transform and -webkit-, -moz-, -ms- and -o- prefixes will be pre-pended.

If you’ve used box-sizing: border-box in your CSS, you’ll also be pleased to hear that width, innerWidth, innerHeight, outerWidth, outerHeight methods are now calculated correctly.

Advanced Animations

The jQuery team admit that animation code had become a little unwieldy. This has been addressed and animation performance has improved as a result.

However, I suspect the days of jQuery and JavaScript-powered animation are numbered. It will never disappear completely but CSS3 offers better and faster effects with less code. Fortunately, you don’t need to include jQuery’s animation methods if you don’t need them…

Increased Modularity

jQuery 1.8 is a few hundred bytes smaller than version 1.7.2, but it’s possible to reduce it further using the grunt-based build system to strip out features you don’t require.

Bugs Squished

Finally, jQuery 1.8 fixes more than 160 bugs. The code base was already rock-solid, so it’s amazing they found so many issues to address.

Time to Upgrade?

Those using v1.7.x can probably switch to 1.8 without incurring significant problems. Older versions should be fine too, but be prepared for some rigorous testing.

That said, issues are often reported within a few days of release so those of a more cautious nature may prefer to wait a few weeks for jQuery 1.8.1.

jQuery is available at jQuery.com. CDN-hosted versions will appear shortly.