I’ve been reading a little about htmx: a JavaScript library which lets you declaratively define actions on page elements that call web API endpoints (without a page refresh), those return HTML snippets, and the snippets are inserted into the live page at defined points.
I thought that was pretty interesting and I wonders if there are opportunities to deploy it to enhance ikiwiki. What do you think? Examples:
- edit page. Could generate and populate the edit form within the loaded page without a full refresh
- edit preview. Could be on demand within the edit page, or even automatic
- comment moderation. Handle deleting spam, approving comments and rebuilds etc asynchronously
- posting comments without leaving the parent page
One thing I’m not sure about is the principle of graceful degradation. That’s something we probanly want in ikiwiki: no JavaScript, things work as normal. I’m fairly sure this isn’t something modern web developers are interested in, so I don’t know to what extent it’s possible with htmx.
Thoughts?
—Jon, 2024-08-20
I'm not sure. We already have jquery in ikiwiki (or at least it's there in my site) and it's one of those huge blobs i'd like to get rid of.
I'd love to have more "live" previews, but the blocker for this right now is not, IMHO, Javascript or browser-level interactivity, it's how slow ikiwiki is over CGI. There's a single CGI endpoint that has huge lock contention: that's most of where people spend time when doing comments or, frankly, anything, through the web interface.
Unless we fix that first, i doubt any live thing like this will be anywhere near useful... I'm also not convinced we need htmx to do the things you're refering to here, but i'm not a frontend developer and i'm old, so i could very well be wrong about that. -- anarcat
I agree, the big locks are a pressing issue and will limit the usefulness of anything like this.
I’d hope that something like this could be optional, and unless opted in you wouldn’t pay the price (= need to bundle the js)
I’m sure the same could be achieved without htmx, but it might be an especially quick/ergonomic way to achieve it.
Some quick notes. the htmx library is tiny: 49567 bytes. To make the "add comment" form embed into the current page onclick, instead of a page refresh, requires the following adjustments to the "add comment" anchor tag:
i.e. the four new attributes. That's it! Obviously some significant refinements could be made, but I'm pretty amazed how little is needed to get something functional working.