After almost 10 years since the release of version 3.0 and 20 years after the project's founding, the jQuery 4.0 JavaScript library has been released, which is used by 70.9% of the top 10 million most visited websites on the network according to W3Techs. The jQuery code is licensed under the MIT License.
The release of jQuery 4.0 contains changes that break backward compatibility, but developers assure that most users will be able to transition to the new version with minimal changes to their code. To facilitate migration, a special plugin can be used. The compatibility breaks are related to the removal of outdated code, the elimination of some undocumented internal parameters, the discontinuation of support for overly complex behavior, and the phasing out of APIs previously marked as deprecated. The removal of deprecated APIs and browsers has reduced the size of the gzip archive with the library by 3 KB (the slim version now takes 19.5 KB, and the full version takes 27.5 KB).
Among the changes:
- Support for IE 10 and older versions has been discontinued (support for IE 11 is still available but will be removed in jQuery 5.0), as well as for other older browsers such as Edge Legacy, Android Browser, and Firefox versions prior to 115.
- Built-in support for the Trusted Types API has been introduced to protect against DOM manipulation leading to cross-site scripting (DOM XSS). This includes improper handling of user-provided data in eval() blocks or inserts using '.innerHTML', which can lead to the execution of JavaScript code in the context of a particular page. HTML code in the form of TrustedHTML objects can now be passed to jQuery methods.
- The jQuery code has been transitioned to use ESM (ECMAScript Module) JavaScript modules and can be supplied and imported as a module.
- Functions previously marked as deprecated have been removed: jQuery.isArray, jQuery.parseJSON, jQuery.trim, jQuery.type, jQuery.now, jQuery.isNumeric, jQuery.isFunction, jQuery.isWindow, jQuery.camelCase, jQuery.nodeName, jQuery.cssNumber, jQuery.cssProps, and jQuery.fx.interval. It is recommended to use standard JavaScript functions such as Array.isArray(), JSON.parse(), String.prototype.trim(), and Date.now() instead.
- Undocumented internal methods of the Array object — push, sort, and splice — have been removed.
- The order of event handling for focus changes has been aligned with the W3C specification — blur, focusout, focus, and focusin.
- The size of the slim version, which does not contain ajax modules and effects, has been reduced to 19.5k by eliminating Deferred objects (it is recommended to use native Promises) and Callbacks.
Source: opennet.ru
