{
  "id": 8221738,
  "title": "htmx 4.0: a Fetch-Based Rewrite, Built-In Morphing Swaps, and Explicit Attribute Inheritance",
  "url": "https://urgent.news/2026/09/18/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-18T09:32:00.000Z",
  "source": {
    "name": "InfoQ",
    "slug": "infoq",
    "url": "https://www.infoq.com/news/2026/09/htmx-4-released/"
  },
  "original_language": "en",
  "account": "HTMX 4.0, the latest release of the hypermedia library, has been rolled out after eight months of development. Creator Carson Gross announced the leap to InfoWorld, expressing surprise with the word \"Oops.\"\n\nThe rewrite of HTMX swaps its long-serving XMLHttpRequest transport for the modern fetch() API, unlocking native streaming while maintaining a script size around 14KB. Most developers will find the familiar hx-get and hx-post attributes unchanged, but the shift enables two key features: built-in morphing swaps powered by idiomorph to preserve DOM state such as input focus during updates, and a new hx-partial tag that allows a single response to cleanly update several targets, offering a cleaner approach to out-of-band swaps.\n\nExplicit attribute inheritance is now introduced, meaning parent attributes reach children only when marked with an :inherited suffix. Developers are advised to watch out for this trap, as an hx-headers attribute passing a CSRF token to child elements may no longer work silently, causing servers to reject requests with a 403 when nothing appears broken.\n\nEvent names have been standardized to a htmx:phase:action pattern, so htmx:afterRequest has become htmx:after:request. Additionally, history no longer snapshots the DOM into localStorage; instead, pages are refetched to ensure third-party scripts function properly.\n\nHacker News passed 700 points with praise for the Go, SQLite, and HTMX stack and the library's compatibility with AI assistants like Claude. Meanwhile, comments from r/htmx and other platforms noted that HTMX forces the mixing of presentation with business logic, leading some teams to consider moving back to React.\n\nThe release ships under npm's next tag rather than the latest tag, preventing force upgrades on unversioned CDNs. HTMX 2.x continues to be supported indefinitely. The team has also introduced a command line checker to flag inheritance issues, renamed attributes, and old events. Notable changes include a 60-second request timeout and various attribute renames, such as hx-disable becoming hx-ignore, which require careful application.\n\nA comprehensive \"What's New in HTMX 4\" guide and dedicated skills files for LLM-assisted upgrades are available. HTMX, an open-source library, adds AJAX, CSS transitions, WebSockets, and server-sent events directly to HTML through attributes, enabling developers to build modern interfaces with minimal JavaScript. It remains a flagship of the hypermedia movement, popular among Django, Go, and Rails backends where server-rendered HTML meets low client-side complexity.",
  "summary": "htmx 4 has been released, featuring a transition from XMLHttpRequest to the fetch() API, enhancing streaming capabilities. Key updates include built-in morphing swaps for DOM state preservation and an hx-partial tag for cleaner updates. Attribute inheritance is now explicit, with event names standardized. The library maintains focus on minimal JavaScript while remaining popular among frameworks.…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}