Get AI summaries of any video or article — Sign up free
Maybe HTMX Is Bad... thumbnail

Maybe HTMX Is Bad...

The PrimeTime·
5 min read

Based on The PrimeTime's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

HTMX property inheritance is criticized for creating non-local behavior across modules, especially because some directives are inherited while others are not.

Briefing

HTMX’s core promise—server-driven UI updates that behave predictably—gets undermined when its implicit rules collide with real browser state and with other UI frameworks’ ideas about DOM ownership. Critics point to “inheritance” of HTMX properties as a particularly costly abstraction: it behaves like CSS inheritance, but unlike CSS it can reach across modules, creating non-local behavior that’s hard to reason about and easy to misremember (for example, some HTMX directives are inherited while others are explicitly not). The result is a workflow where developers end up overriding more and more, making inheritance feel pointless and pushing teams toward being explicit everywhere.

A second cluster of complaints targets how HTMX handles DOM replacement and request queuing. Browser-local state—such as whether a <details> element is open, whether an input/dropdown is currently expanded, or other UI state not represented in attributes—can be lost when outer HTML is replaced “wholesale.” Even when libraries try to patch around specific cases (like avoiding messing with input and details elements), the underlying model still feels brittle: replacing the wrong boundary (the element vs. its contents) can produce jarring UI behavior. On the networking side, HTMX’s default request queue behavior is described as unintuitive: requests triggered on the same queue element can cancel inflight work or otherwise drop earlier operations, which is likened to autocomplete systems that must avoid showing stale results. The criticism isn’t that cancellation exists, but that the default semantics are surprising enough to risk losing work.

The conversation widens into a broader systems problem: state synchronization. When a page mixes HTMX with React, both frameworks effectively try to manage the DOM and component state, creating “fighting” between React’s virtual DOM and the real DOM mutations caused by HTMX. That mismatch can lead to clobbered updates and confusing ownership boundaries. React’s approach to state—props, internal component state, and patterns like global state via Redux—doesn’t automatically solve the integration problem; instead, it can amplify it by spreading state logic across a tree and then requiring additional mechanisms (context, global stores) to keep everything consistent.

Still, the critique isn’t framed as “HTMX is useless.” The strongest alternative proposed is to align the architecture so the server and client behave like one system. React Server Components are offered as a direction where the server renders state and streams updates that React can reconcile, reducing the need for special bridges and potentially avoiding HTMX’s morphing and input/state edge cases. The practical takeaway is that HTMX’s strengths—server-side rendering, type-safe business logic, and avoiding client/server divergence—work best when the rest of the stack doesn’t demand client-side DOM/state control.

The thread ends with a meta-lesson about adopting new tools: developers should learn the “colloquial behavior” of a technology and adopt its vernacular rather than forcing it to match another framework’s expectations. In that light, the harshest conclusion becomes less “HTMX is bad” and more “HTMX plus React is a difficult pairing when both try to own state and DOM behavior.”

Cornell Notes

HTMX’s implicit rules and DOM-replacement model can clash with browser-local UI state and with other frameworks’ DOM ownership. Property inheritance is criticized as non-local and exception-heavy, pushing teams toward overriding everything. DOM replacement can reset state like open/closed details or dropdown/input behavior unless developers carefully choose what gets replaced. Request queuing defaults are also described as unintuitive, risking lost or stale work. The biggest integration pain appears when HTMX is combined with React, since React’s virtual DOM and component state can conflict with HTMX-driven DOM mutations; a proposed future direction is server-first reconciliation via React Server Components.

Why is “inheritance of HTMX properties” treated as a design mistake rather than a convenience?

Inheritance is described as behaving like CSS inheritance—cheap and convenient—but it becomes “non-local.” Properties can unexpectedly apply across modules, making behavior harder to predict. The discussion also highlights exception cases (for example, some directives like HX delete are not inherited while others like HX confirm and HX extensions are), which forces developers to memorize rules. When inheritance is unreliable, teams end up overriding properties on children anyway, making inheritance feel pointless and increasing explicitness everywhere.

How does wholesale DOM replacement create problems with real browser UI state?

Many UI states live in the DOM element itself rather than in attributes. Examples raised include whether a <details> element is open, the open/closed state of dropdown-like controls, and the current value/state of inputs. If HTMX replaces the outer HTML of such elements, the browser-local state can reset, causing the UI to “jump” or close unexpectedly. Even when patches avoid touching certain elements, the boundary choice matters: replacing the element vs. replacing only its contents can change whether the state persists.

What’s controversial about HTMX request queuing semantics?

The default queuing behavior is portrayed as “bonkers” because it can cancel or drop earlier queued work when new operations target the same queue element. The criticism is that this can be highly unintuitive and may lose work. A counterpoint compares it to autocomplete behavior, where earlier requests shouldn’t be shown once the user continues typing; however, the debate centers on whether HTMX’s default semantics match developers’ expectations in general, not just autocomplete-like flows.

Why does combining HTMX with React lead to “fighting” over state and the DOM?

React maintains a virtual DOM (a client-side cache of UI structure) and reconciles it to the real DOM. HTMX, meanwhile, mutates the real DOM directly via server-driven updates. If React and HTMX both assume they control the DOM and component state, React can clobber HTMX changes or HTMX can invalidate React’s assumptions, producing inconsistent UI and hard-to-debug behavior. Web components are mentioned as a partial isolation mechanism because they can separate component DOM from the surrounding HTMX-managed DOM.

What architectural direction is proposed to reduce these integration issues?

A future direction is to re-align server and client reconciliation so React can treat server-rendered state as part of its own reconciliation process. React Server Components are cited as an approach where the server renders state and streams updates that React reconciles, potentially eliminating the need for special bridges and avoiding HTMX morphing/input edge cases. The goal is to make server and client behave like one system, reducing DOM/state ownership conflicts.

Review Questions

  1. Which HTMX behaviors are described as non-local or exception-heavy, and how does that affect developer mental models?
  2. Give two examples of browser-local UI state that can be lost when outer HTML is replaced, and explain why replacing only inner content might behave differently.
  3. What specific ownership conflict arises when React’s virtual DOM reconciliation meets HTMX’s real DOM mutations?

Key Points

  1. 1

    HTMX property inheritance is criticized for creating non-local behavior across modules, especially because some directives are inherited while others are not.

  2. 2

    Wholesale outer HTML replacement can reset browser-local UI state (e.g., open/closed details and dropdown/input states) unless updates target the right DOM boundary.

  3. 3

    HTMX’s default request queue behavior is described as unintuitive, with cancellation/dropping semantics that can risk losing work or producing surprising results.

  4. 4

    The biggest integration pain emerges when HTMX and React both try to manage DOM/state, leading to clobbered updates and inconsistent ownership between virtual DOM and real DOM.

  5. 5

    Web components are suggested as an isolation strategy that can reduce DOM ownership conflicts with HTMX.

  6. 6

    React Server Components are proposed as a reconciliation-focused direction that could reduce the need for HTMX/React bridging and mitigate morph/input/state issues.

  7. 7

    A broader lesson is to learn a tool’s “colloquial behavior” and adopt its vernacular rather than forcing it to behave like another framework’s model.

Highlights

Property inheritance in HTMX is likened to CSS inheritance, but the non-local reach and directive exceptions make it harder to reason about than the convenience suggests.
Replacing outer HTML can wipe browser-local state like whether a <details> element is open, making “wholesale replacement” feel jarring in real UI flows.
The most severe conflict is React + HTMX: both can try to own DOM/state, so React’s virtual DOM reconciliation and HTMX’s real DOM mutations can clash.
React Server Components are presented as a path toward server/client unity, potentially avoiding HTMX morph and input/state edge cases.

Topics

  • HTMX Critique
  • DOM State
  • Request Queues
  • React Integration
  • React Server Components

Mentioned

  • DOM
  • HTMX
  • HX
  • DSL
  • GraphQL