On 17 November 2026 the jQuery team shipped two releases at once: jQuery 4.1.0, the first minor release of the 4.x line, and jQuery 3.8.0, which the team calls “a send-off, not a comeback”. From now on, 3.x only gets critical security and bug fixes. Both releases also fix a ReDoS (regular-expression denial of service) problem in the selector engine, so this is an upgrade worth doing even if you do not care about new features.
This guide covers what is new, the security fix, and a practical plan for moving from 3.x to 4.1. Source: the official jQuery 4.1.0 and 3.8.0 release post and the jQuery 4.0 upgrade guide.
Install or update
npm install [email protected]
# or, if you must stay on 3.x for now
npm install [email protected]
From the CDN:
<script src="https://code.jquery.com/jquery-4.1.0.min.js"></script>
<!-- Slim build, without Ajax and effects -->
<script src="https://code.jquery.com/jquery-4.1.0.slim.min.js"></script>
The security fix: ReDoS in selector identifiers
The regular expression jQuery used to match identifiers in selectors could backtrack catastrophically. A long chain of hex escapes followed by an invalid character, for example inside an attribute selector, could hang the page. The fix makes the pattern exclude digits and hex characters where the CSS spec says it should.
Why it matters: if your code ever builds a selector from user input, a crafted value could freeze the tab.
// Risky on older versions if `term` comes from the URL or a form
const term = new URLSearchParams(location.search).get('tag');
$(`[data-tag="${term}"]`).addClass('active');
Upgrading removes the ReDoS, but the better habit is to avoid building selectors from raw input at all. Filter instead:
const term = new URLSearchParams(location.search).get('tag') ?? '';
$('[data-tag]')
.filter((_, el) => el.dataset.tag === term)
.addClass('active');
Or escape the value with CSS.escape() when you really need a selector:
$(`[data-tag="${CSS.escape(term)}"]`).addClass('active');
Both 4.1.0 and 3.8.0 include the fix.
New in 4.1.0
jqXHR.responseURL
jqXHR now exposes responseURL: the final URL after any redirects the browser followed. It follows the same pattern as responseText and responseJSON, so it is only set when the transport can report it. Modern browsers’ XHR provides it; IE 11 and the script and JSONP transports do not.
$.ajax({ url: '/short/abc123' })
.done((data, status, jqXHR) => {
if (jqXHR.responseURL && !jqXHR.responseURL.includes('/short/')) {
console.log('Redirected to', jqXHR.responseURL);
}
});
This is handy for detecting a session timeout that redirected an Ajax call to a login page.
Form-associated custom elements now serialize
Custom elements registered with formAssociated = true now work with .serialize() and .serializeArray(). Anything listed in form.elements is treated as submittable instead of being filtered out by tag name.
class StarRating extends HTMLElement {
static formAssociated = true;
#internals = this.attachInternals();
#value = '0';
get name() { return this.getAttribute('name'); }
get value() { return this.#value; }
set value(v) { this.#value = String(v); this.#internals.setFormValue(this.#value); }
}
customElements.define('star-rating', StarRating);
<form id="review">
<input name="title" value="Great book">
<star-rating name="stars"></star-rating>
</form>
<script>
document.querySelector('star-rating').value = 4;
console.log($('#review').serialize()); // title=Great+book&stars=4 expected
</script>
Test this with your own components, since how a custom element exposes name and value is up to you.
CSS methods in XML documents
In non-XHTML XML documents, such as XSLT-transformed pages, elements created with document.createElement have no style property. jQuery now uses createElementNS with the XHTML namespace internally, so .css() and related methods work there.
querySelectorAll everywhere
jQuery no longer uses getElementsByTagName or getElementsByClassName internally. It relies on querySelectorAll, which the team says is on par with or faster than the old methods in today’s browsers. The switch also fixes bugs such as selectors with leading combinators on document fragments and tag names containing dots. Invalid escape sequences in selectors are now decoded to U+FFFD, as the CSS spec requires.
Faster uniqueSort
jQuery.uniqueSort now removes duplicates in a single pass. The team describes it as going from O(N²) time to O(N) time with constant extra space. Behaviour and ordering are unchanged.
New transport callback style
Custom Ajax transports can now call their complete callback with a single object instead of positional arguments:
// Old style, still supported
completeCallback(status, statusText, responses, headers);
// New style
completeCallback({ status, statusText, responses, headers });
Only plugin and transport authors need to care, but the object form makes future parameters easier to add.
What is in 3.8.0
3.8.0 mainly releases fixes that sat on the 3.x branch for years. Two things stand out:
.attr('hidden', 'until-found')now keeps theuntil-foundvalue instead of treatinghiddenas a plain boolean.- APIs removed in 4.0 are now formally deprecated in 3.x, so jQuery Migrate can warn you: the
push,sortandsplicemethods on the jQuery prototype, andjQuery.expr[":"]/jQuery.expr.filters(usejQuery.expr.pseudos).
// Before
$elems.push(elem);
jQuery.expr[':'].visibleText = fn;
// After
[].push.call($elems, elem);
jQuery.expr.pseudos.visibleText = fn;
Which version should you pick?
If your site already runs jQuery 4.0, moving to 4.1.0 is a normal minor upgrade: update the package, run your tests and ship. If you are still on 3.x, 3.8.0 is the quick security win, because it keeps the 3.x API while closing the ReDoS issue. Just remember that 3.x will not get new features again, so treat 3.8.0 as a stepping stone rather than a destination.
Upgrade plan: 3.x to 4.1
- Go to 3.8.0 first. It contains the ReDoS fix and the new deprecations.
- Add jQuery Migrate in development and use the app normally. Fix each warning it logs.
- Read the 4.0 upgrade guide for removed APIs and browser support changes.
- Switch to 4.1.0, keep Migrate for a few days in staging, then remove it.
- Test selector-heavy and Ajax code, plus any custom transports and plugins.
Takeaway
jQuery 4.1.0 brings small but useful features like responseURL and custom element serialization, plus a real security fix. jQuery 3.8.0 is the last feature release of 3.x. If you maintain a jQuery site, update to 3.8.0 today for the ReDoS fix, and use Migrate to plan your move to 4.1.
