Almost 10 years after the release of the 3.0 branch and 20 years after the project's founding, the jQuery 4.0 JavaScript library has been released. According to W3Techs, it is used by 70.9% of the top 10 million most visited websites on the web. The jQuery code is distributed under the MIT license.
The release of jQuery 4.0 contains changes that break backward compatibility, but the developers assure most users that they can migrate to the new version smoothly with minimal changes to their code. A dedicated plugin can be used to simplify the migration. The backward compatibility breaks include the removal of deprecated code, the removal of some internal undocumented parameters, the deprecation of some overly complex behavior, and the deprecation of previously deprecated APIs. Removing deprecated APIs and browsers has reduced the size of the gzip archive containing the library by 3 KB (the slim version now takes up 19.5 KB, and the full version 27.5 KB).
Among the changes:
- Support for IE 10 and older browsers has been discontinued (IE 11 support is retained, but will be removed in Query 5.0), as well as other older browsers such as Edge Legacy, Android Browser and Firefox up to branch 115.
- Support for the Trusted Types API has been built in. This API is designed to protect against DOM manipulations that lead to cross-site scripting (DOM XSS), such as incorrectly processing user-supplied data in eval() blocks or ".innerHTML" inserts, which can lead to JavaScript code execution in the context of a specific page. jQuery methods can now accept HTML code in the form of TrustedHTML objects.
- jQuery code has been converted to use ESM (ECMAScript Module) JavaScript modules and can be shipped and imported as a module.
- The following functions have been removed and were previously marked as deprecated: 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 the standard JavaScript functions Array.isArray(), JSON.parse(), String.prototype.trim(), and Date.now() instead of these functions.
- Removed undocumented internal methods of the Array object - push, sort and splice.
- The order of handling focus change events has been brought into compliance with the W3C specification - blur, focusout, focus and focusin.
- The size of the slim version, which does not contain the ajax and effects modules, has been reduced to 19.5k by stopping the delivery of Deferred objects (it is recommended to use the standard Promises) and Callbacks.
Source: opennet.ru
