by recursivedoubts · 4y ago · 0 comments
I'm trying to show where it could go with htmx:
Hypermedia (in particular the uniform interface) is what made the web special and there's no reason HTML can't be improved as a hypermedia along the lines of htmx/unpoly/etc.
We don't need something new. We need to take the original concepts of the web (REST/HATEOAS/Hypermedia) seriously and push the folks in charge of HTML to do the same. Sure, browsers as install-free RPC client hosts works and is occasionally called for, but there is a huge gray area between "applications" and "documents", just waiting for a more expressive hypermedia.
For pete’s sake, just let your server serve html. Replace only the parts of the page that need to update… with html. From your server. The poor thing is just sitting there, idling, bored, borderline depressed because it doesn’t get much of chance to do what it is meant to do, which is, you know… serve. “But it serves JSON” … is like buying a Bugatti Veyron, just to park it in your garage and use its exhaust fumes to dry your clothes 6 days of the week, with a 2 minute drive around the block on Sundays.
That is a very creative analogy, but not one I agree with.
My servers should do as little as possible. They should not serve files just for the sake of it, because they have all these shiny serving features.
And I like JSON as it is not as verbose as html and I can directly work with it in javascript. And then update my html where I need it locally.
If you prefer it differently, than this is fine. The web supports many ways.
Why? It’s not like they wear and tear?
You do realize this means all the user data has to be sent to the cloud? Which is what we want to escape? Hypermedia was created for bots for discoverability, I don't know why anyone would think this is an user-centric concept.
The reason it, and the many other cool libraries can exist is borne out of the strength of the web, namely a solid, accessible foundation of protocols and formats with extensibility via JavaScript.
This last part is incredibly important, because it gives us enough power to create and explore new things, while the web standards can conservatively adopt new capabilities.
The web is working as intended, and while there are many issues and lacking areas (which htmx illustrates beautifully), we can take a step back and appreciate how amazing and empowering a platform it is.
https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arc...
and it has proven to be an incredibly flexible aspect of the web
however, I would note, currently that scripting ability is being used mainly to replace the original hypermedia model of the web (with RPC-style JSON-based applications) rather than enhance it as a hypermedia
we'll see if we can change that
the irony is that DELETE, PUT and PATCH are used today almost exclusively in non-hypermedia JSON data APIs
crazy world!
not much; while you need a little (easily reusable) JS code to use and handle responses to other methods, it's such a tiny fraction of the dev effort that goes into web apps that it makes no meaningful difference.
It would be nice if HTML forms supported other methods for completeness, but it wouldn't save all that much real-world development effort.
These days HTML is really only viewed as a payload carrier for your JS application so doubt that'll ever change either.
To add to both of your arguments, "JS-routers" like SvelteKit/NuxtJS/NextJS are literally reinventing server side rendering for the client to then call the actual server to get data ... to render HTML.
HTMX, LiveView, Livewire, Hotwire etc are escape hatches back to sanity.
It's all done in one call - at least in Svelte. You can even render all this into a fully static site.
Meanwhile htmx and the like is the same idea that was popular 15-ish years ago, which died for good reasons.
this was due to the fact that HTML stopped advancing as a hypermedia, as I say in my original comment
htmx and other libraries are attempting to address that by pushing HTML forward as a hypermedia, which allows you to implement more sophisticated user interfaces purely in hypermedia terms:
the hypermedia idea itself is extremely innovative and interesting and, at some level, today's javascript applications are new iterations of an even older idea: client-server based RPC applications, as we built back in the 1980s
You can perhaps use Alpine.js plus sprinkle htmx here and there, to have the best of both worlds, at least on paper. Didn't try this myself.