JQuery introduces version 4.0.0 after a decade of development

JQuery introduces version 4.0.0 after a decade of development

After nearly ten years, a major update to the popular jQuery JavaScript library has finally arrived with the release of version 4.0.0. Announced on January 17, this milestone update brings significant changes, including support for trusted types, a slimmer build, and updates to browser compatibility.

Trusted Types and Security Enhancements

One of the standout features of jQuery 4.0.0 is its integration with trusted types. This update ensures compliance with a browser’s Content Security Policy (CSP) required-trusted-types-for directive when handling HTML in the TrustedHTML interface. Additionally, adjustments have been made to jQuery’s handling of asynchronous script requests to align with CSP guidelines. While <script> tags are now used for most asynchronous requests to avoid CSP errors, there are still cases where XMLHttpRequest (XHR) is employed, such as when the "headers" option is specified.

A Slimmer, More Modern Build

The new version takes steps to modernise the library by removing deferred objects and callbacks. Although deferreds have supported the Promises A+ standard for JavaScript promises, the wider adoption of native promises makes this feature less necessary. Native promises, now available in all jQuery-supported browsers except Internet Explorer 11, are recommended for most use cases. Developers who still require IE 11 support are advised to use the main build or implement a polyfill for native promises. Notably, jQuery 4.0.0 no longer supports IE 10 or earlier versions.

Breaking Changes and Updated Event Handling

Version 4.0.0 introduces some breaking changes, including a reordering of focus events to match the World Wide Web Consortium (W3C) specification. This update aligns jQuery with the event order used in the latest browser versions, although it differs from earlier implementations. Specifically, the focus event order now follows this sequence: blur, focusout, focus, focusin.

Additionally, internal-only methods have been removed from the jQuery prototype. These methods, including push, sort, and splice, were intended for internal use but did not function like other jQuery methods. Developers relying on these methods are encouraged to replace $elems.push( elem ) with [].push.call( $elems, elem ).

A Library That Endures

Now two decades old, jQuery remains a dominant force in web development, powering 70.9% of all websites according to W3Techs. Despite its age, the library continues to serve as a vital tool for simplifying tasks like HTML document manipulation, event handling, and animation. Managed by the OpenJS Foundation, jQuery’s enduring popularity is a testament to its flexibility and cross-browser compatibility.

With the release of version 4.0.0, jQuery 3.x will now receive only critical updates. This latest version marks a significant step forward for the library, ensuring its relevance in an ever-evolving web development landscape.

Read the source

 

David Brown founded Tucanoo Solutions in 2011 and has written software in a professional capacity for over 30 years, back to the Java/J2EE days of Sun Microsystems. He builds cloud and web applications for clients in legal tech, government and beyond, including several years consulting to the United Nations on customs and transport systems. He writes these tutorials himself, with the full code on GitHub.

Leave a Reply

Your email address will not be published. Required fields are marked *