DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

htmx 4: Key Facts on Package Tags, Changes, and Migration

htmx 4.0.0 is released but remains on NPM’s next tag. Here are the migration changes to check, from explicit inheritance to history restoration and renamed events.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

htmx 4.0.0 was released on August 28, 2026, but it is not the NPM latest release: htmx 2.x remains tagged latest, while htmx 4 is tagged next. The project says it plans to keep those tags in place until some point in early 2027 so sites using non-versioned CDN URLs are not upgraded unexpectedly. So “not latest” describes the package tag, not whether htmx 4 has been released. The htmx project’s release announcement explains the decision.

Why htmx 4 is not tagged latest

NPM’s latest tag still points to htmx 2.x; htmx 4 is published under next. The project’s stated reason is to avoid unexpectedly moving sites that load htmx through non-versioned CDN URLs to a new major version. It says this arrangement is expected to continue until some point in early 2027. That is a release-channel choice, not evidence that htmx 4 is unreleased: version 4.0.0 was released on August 28, 2026. See the official announcement and the htmx project landing page.

As an Amazon Associate I earn from qualifying purchases.

What can break when moving from htmx 2 to htmx 4?

The migration documentation identifies three major behavioral changes: attribute inheritance, HTTP error-response swapping, and history restoration. Event names and the underlying request API also change, so JavaScript hooks deserve a separate audit. The htmx 4 documentation and change catalog are the references for application-specific details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Attribute inheritance is explicit by default

In htmx 2, attributes were implicitly inherited by descendants by default. In htmx 4, inheritance is explicit by default. If a parent element is meant to pass an attribute to its descendants, use the documented :inherited form; :append can extend inherited values. If you need to stage a migration while preserving the old default, htmx 4 documents htmx.config.implicitInheritance as a compatibility setting. Check templates where behavior depends on attributes declared on an ancestor rather than on the element that triggers the request.

HTTP 400 and 500 responses swap by default

htmx 4 changes the default handling of HTTP 400 and 500 responses: those responses are swapped by default, unlike in htmx 2. This can expose server-generated error HTML in places where an application previously expected no swap. Review what the server returns for client and server errors, and test the resulting page behavior. The migration documentation describes htmx.config.noSwap for restoring the older no-swap behavior for statuses such as 204, 304, 4xx, and 5xx; configure it deliberately rather than assuming the old default still applies.

History restoration re-fetches from the server

In htmx 2, history restoration used a snapshot stored in localStorage. In htmx 4, navigating back or forward restores the page by fetching it from the server and swapping the response into the body or the configured history element. The project says this avoids restoring DOM mutations made by third-party libraries without their corresponding JavaScript state. The trade-off is that restoration now depends on a server response and may behave differently from returning to a locally cached DOM snapshot. Test browser back and forward navigation, especially on pages enhanced by third-party scripts. If local restoration is needed, the hx-history-cache extension provides a sessionStorage-based cache.

Event names and event coverage change

htmx 4 standardizes event names into the pattern htmx:phase:action[:sub-action]. For example, htmx:beforeRequest becomes htmx:before:request, htmx:afterRequest becomes htmx:after:request, and htmx:configRequest becomes htmx:config:request.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The release notes also say most error events collapse into htmx:error, HTTP response errors use htmx:response:error, htmx:xhr:* events are removed, and validation events give way to native browser form validation. Search JavaScript listeners and hx-on attributes for old event names, then test the flows those handlers support.

Requests use fetch instead of XMLHttpRequest

htmx 4 replaces XMLHttpRequest with the native fetch() API, and the project says this switch cannot be reverted. It should be transparent for most users, but application code tied to XHR-specific mechanics or hooks needs focused review. In particular, do not rely on removed htmx:xhr:* events.

What is new in htmx 4?

New attributes and extensions

The official change catalog lists new attributes including hx-action, hx-method, hx-query, hx-config, hx-ignore, and hx-validate. It also lists extensions including hx-multipart, hx-live, hx-targets, hx-ptag, hx-csp, hx-download, hx-prompt, and hx-history-cache. The SSE and WebSocket extensions have been significantly rewritten. Treat extensions and custom integrations as migration surfaces: check their htmx 4 documentation rather than assuming their htmx 2 behavior is unchanged. The official change catalog describes these additions.

hx-live and migration tooling

The release announcement describes hx-live as a new front-end scripting solution inspired by Alpine.js, jQuery, and hyperscript. The project also provides an upgrade checker that scans templates and JavaScript for some obsolete attributes, event names, and APIs. Its findings are a starting point, not proof that an application is compatible: it cannot replace tests of server responses, navigation, event-driven code, and extension behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Updated show and scroll syntax

For hx-swap, the combined selector:position form for show and scroll is no longer supported. Use separate modifiers, such as show:top showTarget:#other or scroll:bottom scrollTarget:#other, as documented in the htmx 4 change catalog.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A practical htmx 2-to-4 migration sequence

  1. Pin the version you intend to run. Use a versioned package or CDN reference, following the official installation documentation. Do not rely on an unversioned URL or NPM’s latest tag to select htmx 4.
  2. Run the upgrade checker. Scan templates and JavaScript, then inspect each finding against the relevant code path. The checker identifies some obsolete attributes, event names, and APIs; it does not validate runtime behavior.
  3. Audit inherited attributes. Find behavior that depends on implicit inheritance. Mark intended inheritance explicitly with the documented :inherited form, or use htmx.config.implicitInheritance as a deliberate compatibility measure while migrating.
  4. Exercise error responses. Test server-generated 4xx and 5xx responses in the interface, and confirm whether swapped error content or no-swap behavior is intended. Check the documented htmx.config.noSwap option if the old handling is required.
  5. Test history navigation. Use browser back and forward on pages with dynamic content and third-party DOM libraries. Confirm the server-rendered response produces the expected restored page; evaluate hx-history-cache only if session-based local restoration is appropriate.
  6. Update JavaScript hooks. Rename event listeners and hx-on handlers, and remove dependencies on XHR-specific or replaced validation events. Test each affected request and validation path.
  7. Review extensions and swap syntax. Check custom extensions, SSE and WebSocket integrations, and any combined show or scroll selector-position modifiers against the official htmx 4 change catalog.

How to decide whether to upgrade now

The NPM tag does not make the decision for your application. If you depend on htmx 2 defaults or custom code tied to old events, treat the move as a major-version migration and test the affected behavior before deployment. If you want to evaluate htmx 4, pin it explicitly, migrate deliberately, and keep a rollback path until application-level checks pass. The release and migration sources cited here do not establish a general performance gain or adoption figure, so those should not be assumed as reasons to upgrade.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.