5 ms·
This reads like more of an attack than a question. Even though I prefer React over HTMX, I think the difference is pretty clear, as well as the intention of thi
by woojoo666 4y ago
This reads like more of an attack than a question. Even though I prefer React over HTMX, I think the difference is pretty clear, as well as the intention of this article. In particular, this quote from the article is most relevant
> In HTML-Centric Development, rather than being an afterthought, HTML is embraced as the primary medium of application development. This is in contrast to most SPA frameworks, where a client-side model & the javascript that manipulates it is the central focus.
If you read the authors other post about REST [1], they also talk about how most SPAs communicates with the server via JSON, whereas HTMX uses HTML. This is also part of the HTML centric design. You embed the fetching logic into the HTML, and the server returns HTML directly, so there's less work done on the client, in constrast to most SPA frameworks.
[1]: https://htmx.org/essays/how-did-rest-come-to-mean-the-opposite-of-rest/ https://htmx.org/essays/how-did-rest-come-to-mean-the-opposi...
- encryptluks2 4y agoThe title is literally an SPA Alternative. Should the title then not be updated to an SPA framework, since it isn't an alternative. That is like saying Microsoft Word is an alternative to word processors.
- recursivedoubts 4y agoBut it isn't an SPA framework, it's a generalization of HTML as an alternative to SPA-style frameworks. It's very different conceptually, as different as mobile apps and web 1.0 apps at the network architecture level. I understand that this approach will not appeal to a lot of folks, but on the other hand that's because it is so different than what most of the industry is doing. I hope I understand your criticism correctly here.
- encryptluks2 4y agoThe issue I have is that you're taking the idea of an SPA, which is pretty loose: > An SPA (Single-page application) is a web app implementation that loads only a single web document, and then updates the body content of that single document via JavaScript APIs... Looking at the examples at htmx.org, this is exactly what it does. Just because some car manufacturers decide to put an engine in the front of the car doesn't mean that a car with an engine in the back isn't still a car.
- jaredcwhite 4y agoBut htmx doesn't update the body content of the document via JavaScript APIs. It updates them via HTML APIs. That is, the content coming over the wire from the backend is HTML, not JSON. If you're trying to claim that literally any web page which uses JavaScript in any capacity to update any DOM on the page ever suddenly means it's an SPA, that seems like _quite a stretch_.
- dragonwriter 4y ago> But htmx doesn't update the body content of the document via JavaScript APIs. Yes, it does. > It updates them via HTML APIs. It updates then by using JS code calling DOM APIs. Just like any other SPA. > the content coming over the wire from the backend is HTML, not JSON. The content coming over the wire being HTML, JSON, XML, or text/plain has no bearing on whether the JS framework inserting the result of processing it somewhere on a single pre-existing page is a SPA framework.
- recursivedoubts 4y agohtmx isn't single-page focused, it has features like hx-boost and hx-push-url that are there to explicitly allow the standard URL navigation mechanism of multi-page applications, with the same semantics and conceptual model, history support and so forth as much as possible it tries to stay within the original model of the web, and just generalize it
- woojoo666 4y agoI took the title to mean that HTMX is an SPA alternative, as in, an alternative way to write SPAs that is unlike the common approach. But as other commenters mentioned, HTMX seems to also focus on multi-page applications
- dragonwriter 4y agoSo, it's an HTML-Centric SPA framework. It is still a SPA framework.
- 411111111111111 4y agoSPA stands for single page application. Htmx doesn't limit you to one page/index.html, thus the term shouldn't apply You'll likely only update smaller parts but have multiple pages, with each page having interactivity enabled with htmx
- woojoo666 4y agoI took the title to mean that HTMX is an SPA alternative, as in, an alternative way to write SPAs that is unlike the common approach. But as other commenters mentioned, HTMX seems to also focus on multi-page applications
- majormajor 4y agoI too was also somewhat surprised here because this is a React alternative, not an SPA alternative. SPA in my usage has always been "don't navigate to a new page in the browser, just update the content with JS requests." I thought this would be a new experimental browser or such. "An SPA Alternative" vs "An Alternative SPA" - I had a job in 2011 where we were rendering partials in Rails to send down HTML just to replace certain elements on the page to keep things single-page. We later moved to Backbone to do it more client-side on certain parts. Then I had a job in 2012 where we were in the process of rewriting the site to be a Single Page App with JSON, even. React wasn't released at these points. The SPA term was well established even then.
- woojoo666 4y agoWell the author does seem to wish that HTMX becomes part of the browser [1]. So who knows maybe some day it will be more like an "SPA alternative" and not just an "alternative SPA" [1]: https://news.ycombinator.com/item?id=32158367 https://news.ycombinator.com/item?id=32158367