FAQ
No seriously, why not just use HTMX or Hotwire?
As fantastic as those libraries are, Zjax takes a different approach which we think makes it easier to use. By allowing multiple element swaps with complex behavior to be defined succinctly in a single attribute and including tools for client-side JS binding, Zjax covers a pretty broad spectrum of interactivity which we felt was either lacking or overly complicated with other libaries.
Why not just use React, Vue, or Svelte?
If you're building Trello or Google Docs, by all means, you should probably consider using a SPA framework. But for most web application projects, a full SPA architecture client-side state and navigation is overkill. Using Zjax to handle DOM updates gives you a SPA-like feel without all the complexity.
Why is there no "hx-boost" or "turbo drive"?
Browsers have come quite a long way in recent years. One of the big improvements that went largely unnoticed was something called Paint Holding which dramatically improves basic web page navigation. So now that switching pages doesn't cause a brief flash of white or any other jankiness, the value of "faking" navigation with tools like hx-boost or turbo drive is diminished.
You wanna know what's better than faking navigation and trying to manage the history API so we don't break forward/backward buttons and things like command-click to open a new browser tab? Just using the browser as it was meant to work and letting it take care of all that stuff reliably.
Isn't it too slow and inefficient to download a whole page of HTML?
One of the benefits touted by proponents of SPA frameworks like React is the idea that it's so much more efficient to transport just the bare minimum of JSON data rather than big heavy chunks of HTML.
But when you really look at the lifecycle of an HTTP request, the fact that the payload might be 3 Kb instead of 400 bytes effectively makes zero actual difference. If you're really worried about conserving every last byte of bandwidth, you can always optimize on the server-side to return only the DOM elements required. But for most of us, this is rarely worth worrying about at all.
Is Zjax actually stable enough to use in production?
Yes. Zjax is actually very simple and honestly there just isn't a whole lot that can go wrong. When you include Zjax in your project, it finds any DOM elements with z-swap
or z-action
attributes and attaches event listeners to trigger the specified function. Pretty straightforward.
I found a bug or have a feature request.
Great! Please report any issues here: https://github.com/codepilotsf/zjax/issues.