Tech17 min read

Comparing jQuery 4.1.0 and 3.8.0 Against Older Releases in Chrome and JavaScriptCore

IkesanContents

On November 17, 2026 (US time; early morning November 18 JST), jQuery 4.1.0 and 3.8.0 were released together (official blog, GitHub releases). 4.1.0 is the first minor release in the 4.x line since 4.0.0 came out in January, which I covered previously in jQuery 4.0 is out: a catch-up guide for people who stopped at 1.x.
3.8.0 is the first 3.x release in over three years since 3.7.1 in August 2023, bundling fixes that had accumulated on the 3.x branch. The official blog calls it “a send-off, not a comeback.” In the jQuery README support table, 4.x has Full support, 3.x is now Critical-only (major security and bug fixes only), and 2.x and 1.x are unsupported.

To see how much the selector parsing and AJAX changes in the release notes actually differ from the previous versions (4.0.0 and 3.7.1), I ran all four versions under the same conditions. Before the ReDoS fix, the older releases froze for about 18 seconds on a 63-character selector, while the fixed versions finished in around 1ms. I also found that one of the APIs described in the blog post as removed in 4.0.0 is still present in 4.1.0.

Test Environment

ItemDetails
MachineM1 Max, 64GB RAM
OSmacOS 27.0 (26A428)
BrowserGoogle Chrome 158.0.8127.37 (launched via Playwright)
Safari engineJavaScriptCore jsc bundled with macOS 27.0 (Safari 27.0 on the same OS)
Node.jsv26.12.1
TargetsjQuery 3.7.1, 3.8.0, 4.0.0, 4.1.0 (uncompressed builds from code.jquery.com)
MigratejQuery Migrate 3.6.0 (for 3.x), 4.0.2 (for 4.x)
Loading methodLoaded one version at a time into an empty page from a local HTTP server

Chrome and Node.js use the V8 JavaScript engine, while Safari on macOS uses JavaScriptCore inside WebKit. For the Safari-side checks here, I ran jsc, the command-line runner for JavaScriptCore. Each script loads the four versions in sequence into the same page setup and executes the same code. Items specific to IE 11, legacy Edge, or XML documents were not executed in this Chrome / jsc / Node.js environment and are noted as untested.

Changes Included in Both 4.1.0 and 3.8.0

Three changes highlighted in the official blog apply to both branches: the selector ReDoS fix, the new object-form completion callback for AJAX transports, and unifying the remaining document comparisons inside selector code to loose equality (==) to avoid exceptions in IE and legacy Edge (untested here since it is IE/legacy Edge specific). In addition, the changelog and commit history include a workaround for a Safari 27 regular expression bug in both releases, which is tested in its own section below.

Selector ReDoS Fix

jQuery uses regular expressions to parse identifiers (such as class names and attribute names) from CSS selector strings passed to $( selector ) to select HTML elements. In older versions, the regex branch for hex escapes (like \a or \41) overlapped with the branch for general single-character escapes. When a long sequence of hex escapes was followed by an invalid character, the regex engine retried overlapping combinations exponentially—catastrophic backtracking, or ReDoS (Regular Expression Denial of Service). In code that builds selectors from user input, a crafted string can freeze the browser tab. The fix removes that overlap by following the CSS specification and excluding digits and hex characters from the general single-character escape branch.

The official regression test uses an attribute selector with 30 \a escapes followed by !. I varied the count N of \a sequences in the same pattern and measured how long $( selector ) took in Chrome. Each run used a fresh browser context (isolated cookies and cache) to avoid cross-version interference, taking the median of 3 runs.

var selector = "[" + "\\a".repeat( N ) + "!]";
jQuery( selector ); // Throws a syntax error in all versions
N3.7.13.8.04.0.04.1.0
101.0ms1.0ms1.0ms1.0ms
162.1ms0.8ms2.1ms1.0ms
2019.3ms0.9ms19.3ms1.0ms
24290.8ms0.9ms290.2ms1.0ms
261,149.0ms0.9ms1,152.3ms1.0ms
284,583.1ms0.9ms4,593.0ms1.0ms
3018,301.2ms0.7ms18,342.2ms1.0ms

In the unpatched 3.7.1 and 4.0.0, execution time roughly quadrupled every time N increased by 2 (doubling per \a), reaching about 18 seconds at N=30 (a 63-character selector). Variance across the 3 runs was small, ranging from 18.30s to 18.37s for 3.7.1 at N=30. Because the main thread handling rendering and user input is blocked the entire time, the page becomes unresponsive. Every version eventually throws Syntax error, unrecognized expression, so even code wrapped in try/catch stays frozen until the exception fires. After the fix, 3.8.0 and 4.1.0 threw the exception in around 1ms regardless of N.

The fix pull request (#5807) was opened on March 30, 2026, and the commit message thanks an external reporter. As of November 25, 2026, however, GitHub’s jquery/jquery security advisories still list only two XSS advisories from 2020, and this ReDoS does not appear there.

AJAX Transport Completion Callback

A transport is the mechanism that lets you swap out how $.ajax (jQuery’s function for making requests without reloading the page) performs the actual network call; XHR (XMLHttpRequest) and <script> tag requests are implemented as transports internally as well. Custom transports report completion by invoking a callback function. Previously, arguments had to be passed positionally (meaning their order determined what each value represented), but both releases now also accept a single object.

// Legacy positional form
completeCallback( status, statusText, responses, headers );

// New single-object form
completeCallback( { status, statusText, responses, headers } );

According to the official blog, this makes it possible to add new parameters later without depending on argument order, and 4.1.0 uses it to pass responseURL. I built a custom transport calling both forms and ran $.ajax across all four versions. The positional form succeeded with status 200 in all four versions. The single-object form succeeded only in 3.8.0 and 4.1.0; in 3.7.1 and 4.0.0, the object itself was treated as status ([object Object]), resulting in an error.

Changes in 4.1.0 Only (Diff from 4.0.0)

For changes exclusive to 4.1.0, I tested responseURL on jqXHR, serialization of form-associated custom elements, unifying internal element lookup on querySelectorAll, and the jQuery.uniqueSort speedup. 4.1.0 also fixes CSS methods such as .css() on XML documents (for example after an XSLT transformation), which was not tested here.

jqXHR.responseURL

The jqXHR object returned by $.ajax now exposes responseURL containing the final URL after browser redirects. Using a local server where /redir responds with HTTP 302 (temporary redirect) to /final.txt?from=redir, calling $.ajax( "/redir" ) returned undefined in 3.7.1, 3.8.0, and 4.0.0, and http://127.0.0.1:<port>/final.txt?from=redir in 4.1.0. Just like responseText and responseJSON, it is only populated when the transport can supply it, so it remains undefined in IE 11, <script> and JSONP (the older cross-domain script-loading technique) transports, and in 3.8.0.

Form-Associated Custom Elements

Form-associated custom elements are Web Components (browser-native custom HTML elements) registered with static formAssociated = true so they behave like native form controls such as <input>. Previously, .serialize() and .serializeArray() (which convert form values into submission strings or arrays) filtered elements by tag name and missed custom elements. In 4.1.0, jQuery includes elements present in form.elements.

I placed an <input name="a" value="1"> and a custom element with name="stars" value="5" inside one form and tested .serialize(). At first, I only defined a value getter on the custom element, and even 4.1.0 returned just a=1 without the custom element. Checking jQuery’s implementation showed that after filtering, it checks the element’s name property—and custom elements do not automatically expose a JavaScript name property just from having a name HTML attribute. Adding a name getter (matching jQuery’s own test) made 4.1.0 return a=1&stars=5, while 3.7.1, 3.8.0, and 4.0.0 stayed at a=1.

class StarRating extends HTMLElement {
  static formAssociated = true;
  constructor() { super(); this.internals = this.attachInternals(); } // Internal API for form association
  get name() { return this.getAttribute( "name" ); } // Without this, 4.1.0 still omits it from serialize()
  get value() { return this.getAttribute( "value" ); }
}

Internal Element Lookup Unified on querySelectorAll

jQuery previously used getElementsByTagName and getElementsByClassName internally for tag and class lookups, and 4.1.0 replaces them with querySelectorAll. Because getElementsBy* returns a “live collection” whose contents automatically update when DOM nodes are added or removed, jQuery had to copy it into a plain array to prevent mutations during processing. querySelectorAll returns a static list, removing the need for that copy.

I tested the bug cases tied to the commit in Chrome using the same DOM setups (each expected to match 1 element). The only case that differed in Chrome was a leading combinator inside a DocumentFragment (an off-DOM container): $( "~ span", em ) returned 0 elements in older versions and 1 (the sibling span) in 4.1.0. Selecting a tag name containing a dot (my-component.v2 via find( "my-component\\.v2" )), combining that selector with :contains(''), and finding mo inside cloned MathML (an XML markup language for math notation) all already returned 1 element in Chrome on older versions (the MathML issue was originally reported for IE 11).

Moving to querySelectorAll also makes invalid selector escapes follow the CSS specification by resolving to U+FFFD (the replacement character �). Using elements whose data-attr held either U+FFFD or a NUL character (U+0000) with .filter(), [data-attr='\\D800'] (UTF-16 surrogate range) and [data-attr='\\110000'] (out of Unicode range) matched 0 elements in older versions and matched the U+FFFD element in 4.1.0. For [data-attr='\\0'], the match flipped completely: older versions matched the NUL element, whereas 4.1.0 matches the U+FFFD element.

Faster jQuery.uniqueSort

jQuery.uniqueSort sorts an array of DOM elements in document order and removes duplicates. Older versions removed duplicates one by one with splice. 4.1.0 compacts kept elements toward the front and truncates the tail once, reducing deduplication from O(N²) (quadratic in array length) to O(N) (linear) without changing the output or order.

First, I placed N=50,000 distinct elements directly under body and built a shuffled array containing each element twice (L=100,000). Across 5 runs, the median was about 55.0s on 4.1.0 versus 56.0s on 4.0.0—only a 2% difference. With 50,000 flat siblings, compareDocumentPosition (the DOM call that determines which of two nodes comes first in the document) dominated almost the entire sorting time.

Next, I grouped the N distinct elements into div containers of √N elements each to flatten sibling count and keep the DOM tree shallow, then varied array length L (=2N). I also timed native Array.prototype.sort alone on the same arrays. The table shows medians of 5 runs with min–max in parentheses.

Array length L (distinct N×2)3.7.13.8.04.0.04.1.0Native sort only
5,0006.8ms6.5ms6.8ms6.3ms~5.7ms
20,00044.0ms43.6ms43.6ms40.6ms~36.4ms
50,000244ms (168–404)230ms (169–400)314ms (168–400)149ms (149–151)~136ms
100,0001,214ms (534–1,248)1,506ms (536–1,512)579ms (536–583)447ms (442–452)~416ms

At L=100,000, the older releases split into two bands roughly between 0.53s and 1.5s, whereas 4.1.0 stayed tightly clustered at 442–452ms, close to native sort alone (~416ms). 3.8.0 does not include this optimization and behaved like 3.7.1.

Conversely, on a 200,000-element array repeating only 10 distinct elements, older versions took about 78ms and 4.1.0 took about 73ms. Because the old implementation called splice from the back of the array, leaving only 10 elements at the tail meant very little shifting. The speedup shows up most clearly when an array has many distinct elements that each appear multiple times.

One extra observation: with detached elements not inserted into the DOM, an array of 2N elements left 2N-1 items across all four versions. When neither element is in the document, jQuery’s comparator returns 0 to preserve order, so duplicates are not grouped together during sorting and are not removed—this has always been the behavior.

Safari 27 Regular Expression Bug Workaround

One fix included in both 4.1.0 and 3.8.0 is not mentioned in the blog post body and appears only in the changelog and commit history: a workaround for a Safari 27 engine bug triggered under specific internal conditions, not something most apps hit constantly. According to commit b557a8c4, /a|^x|aa/.exec( "caa" ) matches aa instead of a in Safari 27. WebKit’s regular expression interpreter (the non-JIT execution path) reads the wrong entry—shifted by one position—in its internal list of match candidates when crossing an alternation branch starting with ^, tracked as WebKit Bug 321253.

In jQuery, this affected the regex inside jQuery.escapeSelector, which escapes characters that cannot appear directly in CSS IDs or class names. Because the original regex had a ^-anchored branch in the middle, the fix reorders that branch to the start of the regex in both 3.8.0 and 4.1.0.

Running the minimal reproducer /a|^x|aa/.exec( "caa" ) in jsc returned ["a"] under default settings (with JIT—just-in-time compilation—enabled), and matched ["aa"] when JIT was disabled with --useRegExpJIT=false, matching the commit description.

Next, I extracted the escapeSelector regex and replacer from each version’s source and ran the official test suite’s 198 inputs (33 control characters placed alone, at start, at end, in the middle, consecutively, and in two positions) on both jsc and Node.js v26.12.1 (V8). With jsc JIT enabled and on Node.js (V8), all four versions had 0 mismatches out of 198. With jsc --useRegExpJIT=false, 3.7.1 and 4.0.0 failed 132 of 198 cases—for instance, "a\u0000" should turn the NUL character into U+FFFD (�) to produce "a�", but instead only inserted a backslash before the NUL character, failing to escape control characters from the second character onward. Both 3.8.0 and 4.1.0 passed all 198 cases even with JIT disabled.

Changes in 3.8.0 Only (Diff from 3.7.1)

According to the official blog, most of 3.8.0 consists of fixes already shipped in 4.0.0 (handling <script> elements passed to .html() that remove themselves during execution, fixing jQuery.cleanData skipping elements during cleanup, <col> element width/height fixes, making leverageNative—which bridges native events like focus to jQuery events—more resilient to errors, and feature-support detection fixes under CSS zoom or initially hidden <iframe> elements; none of these were tested here). The two changes specific to 3.x are hidden="until-found" support and formal deprecations preparing for 4.x.

hidden="until-found"

The hidden attribute was originally a boolean attribute with no value, but until-found was later added so hidden content can be revealed automatically by browser find-in-page.

Running $( "<div>" ).attr( "hidden", "until-found" ) and reading the attribute back with getAttribute showed that 3.7.1 normalized it as a boolean attribute and overwrote the value to hidden, turning it into an ordinary hidden element. 3.8.0, 4.0.0, and 4.1.0 all preserved until-found. The official blog notes that 4.x had already changed boolean attribute handling in 4.0.0, so 4.1.0 needed no change.

Formal Deprecations for 4.x

The official blog lists two pairs of APIs as “removed in 4.0.0” and now formally deprecated (still working, but scheduled for removal) in 3.8.0: the array methods on the jQuery prototype $.fn (push, sort, splice; replaced by [].push.call( $elems, elem ), etc.) and jQuery.expr[ ":" ] / jQuery.expr.filters (replaced by jQuery.expr.pseudos).

Checking their types across all four versions turned up a discrepancy. typeof $.fn.push (and sort / splice) was function in 3.7.1 and 3.8.0 and undefined in 4.0.0 and 4.1.0, confirming removal. However, typeof $.expr[ ":" ] remained object in both 4.0.0 and 4.1.0. In the 4.1.0 source, jQuery.expr[ ":" ] = jQuery.expr.filters = jQuery.expr.pseudos; sits alongside deprecated aliases like jQuery.holdReady and jQuery.proxy in both the full and slim (reduced-feature) builds. It was not removed in 4.x and remains as a deprecated alias for jQuery.expr.pseudos.

I also paired each version with jQuery Migrate (the helper plugin that restores removed/deprecated behavior while logging console warnings) and checked the console output.

Combination$el.push()$.expr[ ":" ] / $.expr.filters
3.7.1 + Migrate 3.6.0Warning is deprecatedWarning is deprecated
3.8.0 + Migrate 3.6.0Warning is deprecatedWarning is deprecated
4.0.0 + Migrate 4.0.2Warning is removed (push restored and works)Info is deprecated
4.1.0 + Migrate 4.0.2Same as aboveSame as above

3.7.1 produced the exact same warnings as 3.8.0. Migrate 3.6.0 (released December 2025) already checks for jQuery 3.7.0+ and warns on push, sort, and splice, so those warnings existed before 3.8.0. Migrate 4.0.2 also distinguishes push as removed and jQuery.expr[ ":" ] as deprecated, matching what is actually in the 4.x source. As of November 25 on npm, the latest Migrate versions are still 4.0.2 (January 2026) for 4.x and 3.6.0 for 3.x, with no new Migrate release accompanying this update.

Key Differences Between 4.1.0 and 3.8.0, Plus File Sizes

Both 4.1.0 and 3.8.0 include the ReDoS fix, the Safari 27 escapeSelector fix, the object-form AJAX transport completion callback, and hidden="until-found". Only 4.1.0 includes responseURL, form-associated custom elements in .serialize(), leading combinators in DocumentFragment, U+FFFD conversion for invalid selector escapes, and the uniqueSort speedup. Meanwhile, $.fn.push, sort, and splice remain deprecated in 3.8.0 and are gone in 4.1.0.

Browser support for 4.x is documented in the jQuery Core 4.0 Upgrade Guide: current and previous versions of Chrome, Edge, Firefox, Safari, and Android; current Opera; current and two previous versions of iOS Safari; and IE 11 only. Legacy Edge (pre-Chromium) and IE 10 and earlier are unsupported, and this matrix is set to stay fixed until 5.0. The release blog post does not list a browser support matrix for 3.8.0.

File sizes were measured by compressing the minified builds (.min.js) from the official CDN with gzip -9.

FilePrevious (gzip)Current (gzip)
Full build 4.x (4.0.0 → 4.1.0)27,539 bytes27,639 bytes
Slim build 4.x (4.0.0 → 4.1.0)19,449 bytes19,466 bytes
Full build 3.x (3.7.1 → 3.8.0)30,356 bytes30,609 bytes
Slim build 3.x (3.7.1 → 3.8.0)24,061 bytes24,274 bytes

Both lines barely changed in size compared to their predecessors, and the 4.1.0 full build is roughly 3KB smaller than 3.8.0.

Upgrade Notes

4.0.0 to 4.1.0

The official blog does not list any breaking changes for 4.1.0, though a few edge-case behaviors changed in testing. Most routine updates will not hit these, but code using unusual selectors or custom elements can see differences: selectors containing \0 or UTF-16 surrogate escapes now resolve to U+FFFD (flipping \0 matches), leading combinators like $( "~ span", em ) inside a DocumentFragment now return 1 element instead of 0, and form-associated custom elements with a name property are now included in .serialize(). The new responseURL property remains undefined in environments like IE 11 and JSONP.

3.7.1 to 3.8.0

The main behavior change observed in 3.8.0 is hidden="until-found", which is now preserved instead of being rewritten to hidden. The newly deprecated $.fn.push, sort, splice, and jQuery.expr[ ":" ] still work in 3.8.0, though the first three are removed in 4.0.0. If you write a custom AJAX transport shared across multiple jQuery versions, switching its completion callback to the new object form will break on 3.7.1 and earlier as well as 4.0.0, so keeping positional arguments is required for backward compatibility.

3.x to 4.x

The official blog recommends upgrading to 4.x, stating that most users can migrate with minimal changes. The Upgrade Guide flow is to update to the latest 4.x, load the uncompressed development build of jQuery Migrate 4.x, update plugins and fix console warnings, and then remove Migrate to confirm the app runs on jQuery 4.x alone.

In my testing, loading development Migrate 4.0.2 restored the removed push method while logging an is removed warning. Because removed APIs keep working while Migrate is loaded, removing Migrate at the end to verify behavior is essential. The minified Migrate build restores old behavior without logging warnings. Because Migrate cannot load multiple versions at once, upgrading from 1.x or 2.x requires moving to the latest 1.x/2.x first and stepping through Migrate 1.x and Migrate 3.x.

Here are the breaking changes from the 4.0.0 Upgrade Guide that are most likely to affect existing code.

AreaBreaking changeMigration adjustment
AJAXRemoved automatic JSONP switch when dataType: "json" has a callbackSpecify dataType: "jsonp" explicitly when JSONP is needed
AJAXSame-domain scripts no longer auto-execute without dataType: "script"Set dataType: "script" or use jQuery.getScript
AJAXAsync script loading always uses <script> tagsAllow same-domain scripts in your CSP (Content Security Policy)
AttributesRemoved toggleClass( boolean ) and toggleClass( undefined )Pass the class name(s) explicitly
CoreRemoved jQuery.trim, jQuery.isArray, jQuery.parseJSON, jQuery.now, etc.Replace with String.prototype.trim, Array.isArray, JSON.parse, Date.now()
CoreRemoved callbacks, deferred, and queue from the slim buildUse the full build if you need queue (callbacks/deferred can often use native Promises)
Corerequire("jquery")( window ) no longer works in DOM-less Node.jsUse require( "jquery/factory" )( window )
CSSAuto-appending px to unitless numbers restricted to specific propertiesSpecify CSS units explicitly
EventsStopped shimming focusin and focusoutCheck code relying on IE event ordering with focus and blur
SelectorsRemoved legacy syntax for custom pseudo-classes with arguments (e.g., :custom(arg))Switch to the current jQuery.expr.pseudos syntax

The Upgrade Guide also notes that jQuery 4.0.0 is compatible with jQuery UI 1.13.3 and later. For teams staying on 3.x, the README lists HeroDevs and TuxCare for commercial extended support, with TuxCare newly added alongside the 4.1.0 release.