jQuery 4.0.0‑beta.2: CommonJS/ESM Support, Boolean Attribute Fixes, Slim Build

jQuery 4.0.0‑beta.2 introduces a major rewrite of its testing infrastructure, drops legacy IE support, adds full CommonJS and ESM compatibility with proper export handling, removes special Boolean attribute logic, fixes element position calculations in tables, and offers a slimmer build that omits ajax and deferred modules.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
jQuery 4.0.0‑beta.2: CommonJS/ESM Support, Boolean Attribute Fixes, Slim Build

Overview

In February of last year the jQuery team released the first beta of jQuery 4.0.0. The second beta is now available, with a candidate release expected soon. This beta contains a substantial rewrite of the testing infrastructure, removal of all deprecated or insufficiently supported dependencies, and a critical fix to the bundler’s export fields.

Many breaking changes that have been planned for years are finally possible in a major version: legacy code has been trimmed (including dropping support for IE 11 and earlier), deprecated APIs have been removed, undocumented internal parameters of public functions have been eliminated, and overly complex “magic” behaviours have been abandoned.

A comprehensive upgrade guide will be published before the final release, outlining removed code and migration steps. The jQuery Migrate plugin will be ready to assist. The beta can be fetched via the official CDN or npm; third‑party CDNs will host the final release later.

CommonJS + ESM

jQuery can be consumed in many ways, and supporting both CommonJS and ESM environments simultaneously is challenging. The new solution supports named and default exports, ensures jQuery is only included once even when both import and require are used, and works with bundlers such as Rollup, Webpack, and Parcel. Details are available in the related pull request, and a wiki page explains how the

package.json
exports

field behaves in 4.0.

Boolean Attributes

The HTML specification defines boolean attributes that are either present (treated as true) or absent (treated as false). Historically jQuery’s .attr() API handled these attributes specially:

For getters, if the attribute existed, the lower‑cased attribute name was returned, ignoring any value.

For setters, passing false removed the attribute; otherwise the passed value was ignored and the attribute was set (the name is no longer lower‑cased in jQuery ≥ 3).

Some specifications occasionally map boolean attributes to other values with special behaviour (e.g., the new "until-found" value for the hidden attribute). Because of this, using .attr() to set such values is impossible without breaking existing behaviour. The patch removes all special handling: getters now return the raw value, setters store the provided value, with one exception—passing the boolean false removes any non‑ARIA attribute. ARIA attributes remain unaffected; they can be removed with .removeAttr() or by passing null to .attr().

Element Position in Tables

jQuery 4.0.0‑beta.2 fixes inconsistencies when locating element positions inside tables. Previously, the position of an element depended on whether its parent had position: static or position: relative. The new behaviour returns positions relative to the same container for both cases.

<div id="container" style="position: relative;">
    <table>
        <tr>
            <td>
                <span id="static"></span>
                <span id="relative" style="position: relative;"></span>
            </td>
        </tr>
    </table>
</div>

Earlier, $('#static').position() returned a position relative to the enclosing <td>, while $('#relative').position() returned a position relative to #container. Now both calls return positions relative to #container.

Download

The files are available from the jQuery CDN or can be linked directly:

https://code.jquery.com/jquery-4.0.0-beta.2.js

https://code.jquery.com/jquery-4.0.0-beta.2.min.js

They can also be installed via npm:

npm install [email protected]

Slim Build

A “slim” build is provided for projects that do not need Ajax or the legacy Deferred/Callback system. Modern browsers now support native Promises, so the slim version omits those modules, reducing the gzipped size by roughly 8 KB. The slim files are:

https://code.jquery.com/jquery-4.0.0-beta.2.slim.js

https://code.jquery.com/jquery-4.0.0-beta.2.slim.min.js

All download options are listed on https://jquery.com/download/. Third‑party CDNs will receive the files shortly; until then the official CDN can be used.

CommonJSESMBetajQuerySlim BuildBoolean Attributes
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.