jQuery 4.0 Released: Less Legacy, More Modern Web Standards
With jQuery 4, a new major version is released for the first time in years. Less legacy, modern browsers, more security – with manageable breaking changes.
(Image: Trismegist san/Shutterstock.com)
With jQuery 4, the project has released a new major version for the first time in about a decade. For the JavaScript library's 20th anniversary, the development team is saying goodbye to many legacy issues and consistently aligning jQuery with modern browsers, security mechanisms, and build workflows. The release brings breaking changes but should be usable for most projects with a manageable amount of adaptation effort.
Trusted Types, CSP, and Farewell to Old Browsers
One of the most visible changes is that jQuery 4 no longer supports Internet Explorer 10 (IE) and older. Other old platforms like Edge Legacy, the Android browser, or older versions of iOS and Firefox are also out of support. IE 11 remains compatible for now but is slated for removal with jQuery 5. Those who absolutely depend on these old browsers must stick with jQuery 3.x.
jQuery 4 integrates Trusted Types to better comply with modern Content Security Policies (CSP) requirements. Trusted HTML content can be securely passed to DOM manipulations. Additionally, jQuery largely switches asynchronous script loading to <script> tags to avoid CSP errors caused by inline scripts.
Source Code Now as ES Modules
With version 4, the development team has completely switched the jQuery source code from AMD to ES Modules. Instead of RequireJS, the library now uses Rollup, a lean JavaScript bundler for ES Modules. This allows jQuery to be integrated directly into modern toolchains and also used natively via <script type="module"> – including its tests for the module version.
Videos by heise
Deprecations and More Order for jQuery Prototype
With the major release, jQuery is discarding numerous functions that have been marked as deprecated for years (full list see the jQuery blog). These include, among others, jQuery.isArray, jQuery.trim, jQuery.parseJSON, or jQuery.now. Native JavaScript functions already exist for all of them. Together with the removal of IE-specific code, the library shrinks by more than 3 kilobytes (gzip), according to the development team.
Internal array methods such as push, sort, and splice are no longer part of the jQuery prototype. These methods were apparently never intended for public use and behave strictly like the corresponding native array functions again.
Focus Events Now Follow the Standard
jQuery no longer overrides the native behavior of focus and blur events. Instead of the previous jQuery order, version 4 adheres to the current W3C specification. This can affect existing event logic but ensures consistent behavior across all supported browsers.
(Image:Â jaboy/123rf.com)
The enterJS 2026 will take place on June 16th and 17th in Mannheim. The program revolves around JavaScript and TypeScript, frameworks, tools and libraries, security, UX, and more. Discounted early bird tickets are available in the online ticket shop.
Leaner Slim Build
The Slim Build is even smaller: deferreds and callbacks are completely missing. Native Promises cover most use cases and are available in all supported browsers, except for IE 11. This brings the Slim Build to only around 19.5 KB (gzip).
For the upgrade to version 4, the team provides an upgrade guide as well as an updated version of jQuery Migrate. jQuery 4 is available via CDN and npm; additional CDNs are expected to follow soon. More information about the release is available in the post on the jQuery blog.
(mdo)