Core points
.css()
or .animate()
, and ensure that the method is calculated correctly when using box-sizing: border-box
. Nine months have passed since jQuery 1.7 was released, and now we’re ushering in a shiny new version that helps you write less code in less time while maintaining good cross-browser compatibility Sex (current). Let's take a look at the main new features and updates...
More powerful Sizzle selector engine
jQuery's Sizzle selector engine is optimized for performance and efficiency. It depends on the native querySelectorAll
method when available, but even the method has implementation differences between different browsers. jQuery 1.8 eliminates these differences and provides code fallbacks for IE6 and IE7.
Automatic CSS prefix addition
When you use CSS properties in methods such as .css()
or .animate()
, jQuery 1.8 will automatically add any required prefixes. Therefore, you can apply a single transformation, and the -webkit-
, -moz-
, -ms-
, and -o-
prefixes will be automatically added. If you used box-sizing: border-box
in CSS, you will also be happy to hear that width
, innerWidth
, innerHeight
, outerWidth
, outerHeight
,
methods are now calculated correctly.
Improved advanced animationjQuery team admits that the animation code has become a little clumsy. This problem has been solved and animation performance has been improved. However, I suspect that the era of jQuery and JavaScript animation is already a handful of. It never completely disappears, but CSS3 provides better, faster results with less code. Fortunately, if you don't need jQuery's animation methods, you don't need to include them...
Higher modularityjQuery 1.8 is several hundred bytes smaller than version 1.7.2, but can use a grunt-based build system to remove unnecessary features, thereby further reducing its size.
Fixed bugFinally, jQuery 1.8 fixed more than 160 bugs. The code base is already very stable, so it is surprising that they are able to find so many issues that need to be solved.
Does the upgrade need to be made?Users using version 1.7.x may be able to switch to 1.8 without encountering major problems. Older versions should be fine, but they need to be prepared for rigorous testing. That is, problems are usually reported within a few days of release, so more cautious users may be more willing to wait a few weeks until jQuery 1.8.1 is released. jQuery is available at jQuery.com. The CDN hosted version will appear soon.
FAQs about 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 features. 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, modular code bases, and better handling of HTML5 data properties.
jQuery 1.8 has made some improvements to its animation engine. It now uses the requestAnimationFrame
API when available, which can produce smoother animations. It also includes a new feature called "ticker" which allows multiple animations to be synchronized and run at the same frame rate. This can significantly improve performance when running complex animations.
Sizzle is a pure JavaScript CSS selector engine designed to be easily placed into the host library. It has been completely rewritten in jQuery 1.8, improving performance and adding new features. It now supports position selectors, allowing you to select elements based on where the elements are in the document.
jQuery 1.8 introduces better handling of HTML5 data attributes. It now automatically converts data properties to the corresponding JavaScript type. For example, data attributes containing numbers will be automatically converted to JavaScript numbers, and attributes containing JSON objects will be converted to JavaScript objects.
jQuery slider has both positive and negative effects on SEO. On the positive side, they can make your content more engaging and interactive, which can increase user engagement and website stays. However, if implemented improperly, they can also hide the content of search engines or slow down the website, thus damaging your SEO.
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 need to manually parse the response data. For example, if you specify "json" as dataType
, jQuery will automatically resolve the response to a JSON object.
jQuery 1.8 introduces a modular code base, which means that the code is organized into separate modules according to the functionality. This makes the code easier to maintain and understand. It also allows you to include only the required modules, which reduces the size of the jQuery file and improves performance.
jQuery 1.8 introduces several performance improvements. Rewriting of the Sizzle selector engine improves the selection speed of elements. For animations, use the requestAnimationFrame
API can produce smoother animations. Modular code bases can reduce the size of jQuery files and increase loading time.
jQuery 1.8 introduces better support for the CSS3 transition. It now contains a transition function that allows you to animate transitions between two states. This can produce smoother, more visually appealing animations.
jQuery 1.8 introduces some new features and improvements that can make your web development easier and more efficient. Improved Sizzle selector engine, automatic type conversion for Ajax, and better handling of HTML5 data properties can save you time and reduce the amount of code you need to write. Improved animation and modular code bases can improve the performance and user experience of your website.
The above is the detailed content of What's New in jQuery 1.8. For more information, please follow other related articles on the PHP Chinese website!