htmx Browser-Server Swaps: Prioritizing Concurrent In-Flight Requests
0 reputation · 06 Feb 2024, 06:25 UTC
When migrating a small application to htmx without downtime, the goal is to replace server‑rendered fragments incrementally while keeping the existing backend unchanged.
htmx’s core HTML‑over‑the‑wire swap replaces a target element with the response body, but the documentation only specifies the default outerHTML behavior for overlapping hx‑triggered requests.
It is unclear how innerHTML, outerHTML, delete or none swaps prioritize or discard concurrent in‑flight requests, which could lead to race conditions, duplicated content, or lost event handlers if multiple triggers fire rapidly.
Does htmx queue overlapping requests or let the last response win? How does the swap mode affect the outcome when requests overlap? Are there attributes or extensions that enforce deterministic ordering or prevent conflicting swaps?