Interview Q&A · questions with model answers

htmx Interview Questions

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked What is htmx?

    htmx is a small, dependency-free JavaScript library that lets HTML attributes make HTTP requests and swap the HTML the server returns into the page. Any element can send a request, on any event,…

  2. Most asked What do hx-get, hx-post, hx-put, hx-patch and hx-delete do, and how are values sent?

    Each issues a request with that HTTP method to the given URL when the element is triggered. An element sends its own value; a form sends its fields; a non-GET request inside a form also sends the…

  3. Most asked What is hx-target, and what relative selectors does it support?

    hx-target chooses where the response goes; by default it's the element that made the request. It takes a CSS selector or extended selectors: this, closest <sel>, next, next <sel>, previous, previous…

  4. Most asked What swap styles does hx-swap support?

    innerHTML (the default, replace the target's content), outerHTML (replace the target), textContent, beforebegin, afterbegin, beforeend, afterend, delete (remove the target) and none (no swap, but…

  5. Most asked What security risks are specific to htmx, and how do you mitigate them?

    Any XSS becomes more dangerous because injected hx- attributes are activated by htmx (an injected hx-delete with hx-trigger="load" would run). Mitigate by escaping all output, wrapping user HTML in…

  6. Most asked What does 'hypermedia-driven application' mean?

    An application where the server answers with hypermedia (HTML that includes the next possible actions as links, forms and htmx attributes) instead of raw data. The client doesn't need to know the…

  7. Most asked What are out-of-band swaps?

    Elements in a response with hx-swap-oob (and an id) are taken out of the response and swapped into the page elements with the same id, in addition to the main swap. This updates several places from…

  8. Most asked What does hx-boost do?

    hx-boost="true" on a container upgrades its normal links and forms: htmx requests the same URL in the background, swaps the response's body into the current page, updates the title and pushes the…

  9. Most asked What changed in htmx 4?

    htmx 4.0 (August 2026) switched from XMLHttpRequest to fetch() with streaming, made inheritance explicit (:inherited), swaps 4xx/5xx responses by default (except 204/304) with hx-status for control,…

  10. What is hx-sync, and when do you need it?

    hx-sync coordinates requests from elements so they don't race. Strategies: drop (ignore new requests while one runs, the default), abort, replace (abort the running request and send the new one),…

  11. What are htmx's JavaScript API functions you use most?

    htmx.ajax(method, url, target or options) to send an htmx request from code, htmx.process(el) for inserted HTML, htmx.on(event, fn) and htmx.trigger(el, event) for events, htmx.onLoad(fn) for…

  12. What is hx-select, and when is it useful?

    hx-select takes a CSS selector and keeps only the matching part of the response before swapping. It lets htmx reuse endpoints that return full pages (for example with hx-boost or existing…

Was this page helpful?

Report a mistake