Skip to main content

What’s New in jQuery 1.8

By Craig Buckler



Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

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 CDN-hosted versions will appear shortly.

Related Articles

Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.

New books out now!

Learn the basics of programming with the web's most popular language - JavaScript

A practical guide to leading radical innovation and growth.

Integromat Tower Ad