HTMX: HTML-first progressive enhancement against SPA fatigue

HTMX (1.0 November 2020) by Carson Gross: minimal JavaScript library extending HTML with attributes for AJAX requests, WebSocket, SSE. Return to server-rendering with interactivity without SPA framework.

Open SourceWebR&D HTMXCarson GrossProgressive EnhancementHTMLJavaScriptOpen Source

Against SPA complexity

After fifteen years of React/Vue/Angular dominance, a reaction: SPAs are often excessive. For many CRUD applications, dashboards, portals, a server-rendered page with a bit of Ajax would work perfectly. But modern tooling pushes everyone toward heavy stacks (Webpack + Babel + React Router + state management + API layer).

HTMX, created by Carson Gross in 2020 (evolution of intercooler.js from 2013), is a minimal JavaScript library (~14KB) that extends HTML with attributes for AJAX interaction. The philosophy: server returns HTML, client swaps HTML fragments.

HTMX 1.0 is released in November 2020. Around 2022 (1.8) it gains significant adoption momentum. Zero-Clause BSD (0BSD) licence — equivalent of public domain.

The syntax

<button hx-post="/subscribe" hx-target="#result" hx-swap="innerHTML">
  Subscribe
</button>
<div id="result"></div>

When the button is clicked, HTMX sends POST to /subscribe, receives HTML response, inserts it into #result. No custom JavaScript, no JSON API, no state management.

Main attributes:

  • hx-get/post/put/delete/patch — HTTP verbs
  • hx-target — element to place result in
  • hx-swap — how to replace (innerHTML, outerHTML, beforebegin, afterend)
  • hx-trigger — triggering event (click, change, keyup, every 5s, revealed)
  • hx-push-url — push URL in history
  • hx-indicator — spinner during request

WebSocket and SSE

HTMX extends beyond AJAX:

  • hx-ws — bidirectional WebSocket
  • hx-sse — Server-Sent Events for unidirectional push

Enables real-time patterns (chat, notifications, live dashboards) without SPA framework.

HATEOAS revisited

HTMX rediscovers HATEOAS (Hypermedia as the Engine of Application State, Roy Fielding, REST thesis 2000): the server is state’s engine, the client (browser) displays and interacts. Opposite approach to modern SPA architecture where the client is state’s engine and the server is the API.

Server framework partners

HTMX shines with server-side frameworks:

  • Django (Python) — natural integration
  • Rails (Ruby), Phoenix (Elixir), Laravel (PHP)
  • Go templates, Java Spring MVC
  • Node.js Express with template engine (EJS, Pug, Nunjucks)

The server returns HTML partial instead of JSON; no separate “backend for frontend”.

Adoption

HTMX has a dedicated and growing community:

  • Corporate internal tools
  • Admin dashboards
  • Content sites with light interactivity
  • Progressive enhancement of legacy sites
  • Book: “Hypermedia Systems” (2023) by Gross, Stepinski, Akşimşek formalises the philosophy

In the Italian context

Growing 2023-2024 adoption in teams tired of React/Vue complexity for use cases where it is not justified.


References: HTMX 1.0 (November 2020), Carson Gross. Evolution of intercooler.js (2013). 0BSD licence. ~14KB minified. hx- HTML attributes. “Hypermedia Systems” book (2023).*

Need support? Under attack? Service Status
Need support? Under attack? Service Status