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 singletransform
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.Frequently Asked Questions about jQuery 1.8
What are the new features in jQuery 1.8?
jQuery 1.8 introduces several new features and improvements. It includes a complete rewrite of the Sizzle selector engine, which improves performance and adds new capabilities. It also introduces automatic type conversion for Ajax, allowing you to specify the dataType you expect to receive from the server, and jQuery will handle the conversion. Other notable features include improved animations, modularized codebase, and better handling of HTML5 data attributes.
How does jQuery 1.8 improve animation performance?
jQuery 1.8 introduces several improvements to its animation engine. It now uses the requestAnimationFrame API when available, which can result in smoother animations. It also includes a new feature called “tickers,” which allows multiple animations to be synchronized and run at the same frame rate. This can significantly improve performance when running complex animations.
What is the Sizzle selector engine in jQuery 1.8?
Sizzle is a pure-JavaScript CSS selector engine designed to be easily dropped in to a host library. It has been completely rewritten in jQuery 1.8, resulting in improved performance and new capabilities. It now supports positional selectors, which allow you to select elements based on their position in the document.
How does jQuery 1.8 handle HTML5 data attributes?
jQuery 1.8 introduces better handling of HTML5 data attributes. It now automatically converts data attributes to their appropriate JavaScript types. For example, a data attribute containing a number will be automatically converted to a JavaScript number, and an attribute containing a JSON object will be converted to a JavaScript object.
What is the impact of using jQuery sliders for content on SEO?
jQuery sliders can have both positive and negative impacts on SEO. On the positive side, they can make your content more engaging and interactive, which can increase user engagement and time spent on your site. However, if not implemented correctly, they can also hide content from search engines or slow down your site, which can hurt your SEO.
How does jQuery 1.8 handle automatic type conversion for Ajax?
In jQuery 1.8, you can specify the dataType you expect to receive from the server, and jQuery will handle the conversion. This means you no longer have to manually parse the response data. For example, if you specify “json” as the dataType, jQuery will automatically parse the response as a JSON object.
What is the modularized codebase in jQuery 1.8?
jQuery 1.8 introduces a modularized codebase, which means that the code is organized into separate modules based on functionality. This makes the code easier to maintain and understand. It also allows you to include only the modules you need, which can reduce the size of your jQuery file and improve performance.
How does jQuery 1.8 improve performance?
jQuery 1.8 introduces several performance improvements. The rewrite of the Sizzle selector engine results in faster selection of elements. The use of the requestAnimationFrame API for animations can result in smoother animations. The modularized codebase can reduce the size of your jQuery file and improve load times.
How does jQuery 1.8 handle CSS3 transitions?
jQuery 1.8 introduces better support for CSS3 transitions. It now includes a transition function that allows you to animate the transition between two states. This can result in smoother and more visually appealing animations.
What are the benefits of using jQuery 1.8?
jQuery 1.8 introduces several new features and improvements that can make your web development easier and more efficient. The improved Sizzle selector engine, automatic type conversion for Ajax, and better handling of HTML5 data attributes can save you time and reduce the amount of code you need to write. The improved animations and modularized codebase can improve the performance and user experience of your site.
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.