Topic 23 / 40
HTMX & TailwindCSS: Server-Driven UI (SDUI)
1. Deep Architecture
HTMX swaps server-rendered HTML fragments directly into the DOM, avoiding client-side JSON parsing. This reduces Javascript execution overhead and speeds up the first paint. Combined with Tailwind’s utility-first CSS, it simplifies frontend updates.
2. The Feynman Gatekeeper
[KNOWLEDGE CHECK] What is the difference in DOM updates between updating state in React and swapping HTML fragments with HTMX?
3. The Code
# views.py
from django.shortcuts import render
def video_status_partial(request, video_id):
video = Video.objects.get(id=video_id)
if request.headers.get("HX-Request"):
return render(request, "sanjaya/partials/status.html", {"video": video})
return render(request, "sanjaya/full_status.html", {"video": video})
4. The Funnel
Stat Level-Up: Hypermedia Builder (Lvl 1).
Sanjaya Integration: Update the status indicator on the dashboard without reloading the page.