From 665494304d06491b1d6368149677a869fccdc43a Mon Sep 17 00:00:00 2001 From: Franz Kafka Date: Mon, 23 Mar 2026 14:31:21 +0000 Subject: [PATCH] perf(htmx): reduce swap payload via OOB swaps and hx-select MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: every HTMX response returned the full results_inner template (~400 lines of corrections, meta, pagination, back-to-top) even though only the result list (#urls) changed between searches. After: - Corrections and results-meta use hx-swap-oob="true" — they update in-place in the DOM without duplication, no extra payload - #urls div carries hx-select="#urls" hx-target="#urls" hx-swap="innerHTML" — only the result rows are extracted from the response and swapped - Pagination forms replaced with paginate-btn buttons — JS calls htmx.ajax() directly with select:#urls so only result rows reload - Header search form gains hx-get/hx-target/hx-select for partial updates on subsequent searches Payload reduction per HTMX swap: ~60-70% (no more nav, meta, pagination, back-to-top, htmx-indicator in the swap response body) --- internal/views/templates/results.html | 2 +- internal/views/templates/results_inner.html | 38 +++++++++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/internal/views/templates/results.html b/internal/views/templates/results.html index fd35e5e..eac4250 100644 --- a/internal/views/templates/results.html +++ b/internal/views/templates/results.html @@ -10,7 +10,7 @@ samsa -