Drupal 11 Integrates HTMX as Potential Successor to AJAX Subsystem
The article “Drupal 11: Making Interactive Elements With HTMX,” written by Phil Norton and published on Hashbangcode, examines how the HTMX library is being integrated into Drupal 11 to support interactive interfaces without custom JavaScript. The approach uses HTML attributes to trigger server requests and dynamically update page elements, aligning with Drupal’s strength as a system that generates structured HTML responses.
The article outlines how Drupal incorporates HTMX through built-in libraries such as core/htmx and core/drupal.htmx, along with backend tools including the \Drupal\Core\Htmx class and HtmxRequestInfoTrait. These allow developers to attach HTMX attributes to render arrays, detect HTMX requests, and return specialised responses. Because Drupal responds with full HTML pages, developers must use HTMX attributes to target and replace specific elements within the response.
HTMX became fully available in Drupal 11.3.0 after appearing experimentally in 11.2.0, and the article notes that the long-term goal is to replace Drupal’s existing AJAX subsystem with an HTMX-based approach. However, adoption within core remains limited, meaning both systems are expected to coexist while contributed modules and core features gradually transition.


