jQuery 4.0.0 is Here: Celebrating 20 Years of the Web’s Most Iconic Library

It feels like only yesterday that John Resig stood at BarCamp NYC and introduced a revolutionary way to traverse the DOM. That was January 14, 2006. Today, exactly 20 years later, we are beyond thrilled to announce the final release of jQuery 4.0.0. This isn’t just a version bump; it is a milestone release representing nearly a decade of development, modernization, and a commitment to the evolving web ecosystem.

As the first major version release since 2016, jQuery 4.0.0 brings the library into the modern era while staying true to the philosophy that made it a staple of web development. While this release includes several breaking changes necessary for the health of the project, we’ve worked hard to ensure the upgrade path is as smooth as possible for the millions of sites that rely on us every day.

Trimming the Fat: A Leaner, Modern Core

For years, the jQuery team has wanted to clean up legacy code that was held in place by our commitment to backward compatibility. With 4.0.0, we’ve finally made those moves. We have removed long-deprecated APIs, eliminated undocumented internal-only parameters, and dropped support for several “magic” behaviors that were often more confusing than helpful.

To assist with this transition, we’ve released a comprehensive upgrade guide and a new version of the jQuery Migrate plugin. These tools will help you identify exactly which parts of your codebase need attention before you fully commit to the new version.

Browser Support: Moving Beyond Legacy IE

The most significant shift in our browser support matrix is the removal of support for Internet Explorer versions older than 11. While some may wonder why IE 11 remains, our strategy is to phase out legacy support in stages; IE 11 support is slated for removal in jQuery 5.0. By dropping IE 10 and older now, we’ve been able to significantly modernize the internal codebase.

Additionally, we have officially dropped support for other “evergreen” precursors, including Edge Legacy, older versions of iOS (pre-v13), and older iterations of Firefox and Android Browser. If your project still requires support for these specific environments, we recommend staying on the jQuery 3.x branch for the time being.

Security-First: Trusted Types and CSP Compliance

Security is paramount in the modern web landscape. jQuery 4.0.0 introduces native support for Trusted Types. This ensures that HTML processed through jQuery manipulation methods can now be wrapped in TrustedHTML, allowing developers to comply with strict require-trusted-types-for Content Security Policy (CSP) directives without jumping through hoops.

We’ve also overhauled how we handle asynchronous script requests. In the past, some AJAX requests utilized XHR, which could trigger CSP violations regarding inline scripts. We have now transitioned most asynchronous script loads to use <script> tags by default. For those who need specific headers on their script requests, we recommend utilizing the scriptAttrs option to maintain CSP compliance.

Under the Hood: The Migration to ES Modules

One of the most exciting technical shifts for the contributor community is the migration of the jQuery source code from AMD (Asynchronous Module Definition) to ES Modules (ESM). While jQuery has long been available on npm, the source itself can now be imported directly in modern development environments with ease.

This architectural shift aligns jQuery with the modern JavaScript standard, making it easier for developers to inspect, contribute to, and bundle the library using contemporary build tools like Vite, Rollup, or Webpack.

How to Get Started

jQuery 4.0.0 is available right now via the jQuery CDN and the npm package manager. While third-party CDNs will likely update their repositories shortly, we recommend checking your versioning constraints to ensure a controlled rollout of these breaking changes. We can’t wait to see what you build with this modernized version of the library that helped build the modern web!

Source: Read the full article here.