After a year of using HTMX, I really like it and would encourage everybody to give it a try.
It's nice for:
- internal tools
- midly dynamic websites
It's not great for any web page you stay a long time on mobile on, though. I made a web app with it, and on my phone, you can't handle the fact the browser plays against you if you stay a long time with a tab open and goes in and out of the app. You really need a lot of control in JS for that.
Also: don't try to avoid JS using it. It's a mistake many people do, and that's not how you get the best out of it.
I regularly sparkle a little vanilla js or alpine in my htmx websites to make them nicer. And in some cases, I even have one lone page that loads a full vue/react because that particular section needs to be way more dynamic. It's not an XOR. You have now a whole spectrum of how dynamic and how much work you want to put in.
Sometimes, I don't write JS at all, but it's not a requirement.
Can you expand on it not being great for sites with long sessions? Why does that play into it at all, wouldn’t the tab just sit there and do nothing? Do you mean if you need interactivity when the user goes in and out of the page?
Unfortunately no, the tab doesn't sit there and do nothing.
Mobile browsers will do all sorts of optimization, such as interrupting the network, slowing down the vm, putting it to sleep, caching and uncaching things without letting you know, and without a predictable pattern.
If you use raw JS, you can deal with all kinds of errors manually, put in place recovery strategies, bust caches, etc.
With HTMX, you just get sluggish behavior, or no behavior at all in your page, and you don't know why.
Also like another person said, you expect your state to be the same, like the scrolling placement, but chrome might decide that no, you get a page refresh there, or you are somewhere else in the page on next switch.
In this particular app, I have a raw JS counter, which is updated on the client to make it snappy, and by htmx to keep it up to date with other modifications. But the counter will be off randomly because Chrome messes with it. So I had to manually put many rules to know it's out of sync, and request the sync at the right moment. But the sync may not happen because Chromes decided so. So I should try several times, with exponential backoff, differentiates the different reasons of failures and update the DOM manually while handling various interactions with other components.
At this stage, you are basically coding a lot in JS instead of getting the state from the server in HTML, so having VueJS + VueRouter + Pinia is going to be easier to manage, and you'll get more interactivity and optimistic updates on top.
It's not worth it. Right tool for the right job and all that.
It's mostly on mobile though. On Desktop, the HTMX app behaves perfectly.
About the counter: without more details, it's hard to judge; by your description, though, it sounds to me as something you shouldn't be doing in the first place.
About the state: there are plenty of ways to have a polymorphic backend responding with fragments or entire HTML pages, depending on state and what's required by the request. Can't see the limitation you guys are talking about.
About the scrolling position, it's actually dynamically loaded content that messes everything. Browsers do a pretty good job keeping scrolling position, as long as the page loads with the same content as before. Which is easy with htmx and very hard to impossible with dynamic content.
If I did this with react, I can use a session storage caching plugin, so how do you prevent the chain of load events on history back and page refresh with htmx?
Now you are looking at service workers...
I mean with a bit of extra JS and some additional APIs, nothing is strictly impossible but it's often that you go back to the architecture board when you are working with it.
I don't dislike it though, not even close. React (and other similar tools) has (have) a place, so does htmx.
Why can't the number of rows loaded be stored in the URL?
You could use hx-push-url [1] every time the scroll triggers loading more rows, updating the total number of rows loaded. When the browser refreshes the page, the backend will know how many rows to return. No need for complicated JS plugins and service workers. Just basic browser feature, HTTP and HTML. You have fewer ways of shooting your own foot.
I think the modern frontend environment have a tendency to look for over complicated solutions.
Most times I see people proposing JS to manipulate the browser, a simpler browser-based solution would be perfectly good.
In most cases when I browse the web, the JS manipulation leads to very poor UX.
Even when the developer is exceptionally good and can deliver better solution than the browser, the advantage gain is so small that it's not worth the effort. Unless you're Facebook and can dillute the high-quality development cost to billions of users.
HTMX has pretty simple controls for pushing history state from either the client or the server for each request.
Add the current page into the URL every time you load a new section and when someone hits 'back', they can be given exactly the same content as they had before
That's one of the main problems I see in frontend development nowadays.
Developers are taught to overkill everything. They implement things naively, admired of how "smart" their "solution" look, compared to a "dumb" browser.
They shoot themselves in the foot all the time. Users suffer with bad UX. Projects move slowly and expensively. Everyone loses.
Depending on RAM limitations, the mobile browser will kill the tab session. When the user comes back, it'll reload the page. But I don't see how this is different for htmx or JS websites.
He might be referring to the problem that URLs are not enough to get to a certain state, which you might run into when trying to share a specific view or when your browser heavily unloads your tab.
I found this to be the biggest issue when building my webpage, I wanted to have a link like /blog/foo, but what exists out there is just / and the documents at /blog and /blog/foo are just the small fragments that get loaded once you click your way through /
Ultimately I hacked around it by adding some js to every file beyond /, which redirected to / with some anchor, and having / restore the state through the anchor, but it doesn't look the same as regular links into a website (/#blog-foo vs /blog/foo)
The "HX-Request" header is automatically included for every request triggered by HTMX. You can just check that to know if you should respond with a fragment or the full page.
If you use HX-Request header to overload routes with both normal browser and htmx requests, remember to add `Vary: HX-Request` as well, otherwise the browser may use cached htmx requests when you reload the page.
And now I'm stuck replicating htmx's behaviour on the server side?
Seems doable and not that much of a hassle as fragment replacements should be simple afterall, but I'm simply running my site as a static page for now and I had to hack a redirecting extension for things to sort of work.
> I found this to be the biggest issue when building my webpage, I wanted to have a link like /blog/foo, but what exists out there is just / and the documents at /blog and /blog/foo are just the small fragments that get loaded once you click your way through
Huh? /blog/foo should return the full document. Why did you do it so it depends on the user clicking through links in a certain order?
While self taught can work for some people, for most it does not work out. A big thing on self meditation is that it means you do not have a mediator/moderator.
Possibility of ending up on the path to 'Zen-sickness'
The biggest hurdle is the preconceptions we have about meditation, and the cultural image we carry.
People will try to "be calm", "be zen", they will attempt to "empty their mind". They will look for something special. They will not understand the implications of frustration, impatience, discomfort...
It's very hard by yourself because you bring with you a lot of ideas from a world that doesn't meditate, but certainly has a lot of things they want to claim about meditation no matter how little experience with it they have.
And you won't know when you got in a direction that will not work for you
Just yesterday people downvoted me on HN for suggesting ChatGPT had the best ability to deduct things, because, according to down voters, it didn't have any.
But the "dumb parrot" narrative that was quite fitting on GPT2, and maybe still useful for understanding the foundation of the tech in GPT3, is now just a demonstration of ignorance.
We don't know what they are really doing. Nobody working outside of openai knows.
But if you use it long enough, it will be obvious we have passed the fancy completion phase, there is a little logic in there. Not a lot, but it makes all the results much better already.
I wouldn't be too sure openai people know either. if a machine has enough moving parts, it's hard for an individual human to understand all of it. nowadays it's possible that nobody quite knows why the silicon compiler put a particular block in a particular position on the die. it just figured that's the best way to save power or space or whatever.
For a more informed opinion than folks on the internet, here's some work from Microsoft with early/internal access to gpt4: https://arxiv.org/abs/2303.12712 . I don't think people close by these systems share the same dumb parrot sentiment at all.
I've never been sure what to make of that paper. It was published by Microsoft shortly after Microsoft's big deal with OpenAI and reads a lot like a marketing piece to me. Many of the observations didn't reproduce the same way once ChatGPT4 in public hands too. If nothing else, I'd prefer it come from a party who hadn't just signed a $13 billion dollar deal with OpenAI a few weeks prior with a view to using their products to sell more new products/features... It's somewhat self-serving for Microsoft to argue ChatGPT4 is super-awesome/sparks of AGI etc, regardless of validity of claims.
Not to mention wireless networks like the ones for the airtag or the wifi endpoints mapping google has could be adapted to share positions of "right here, right now" anonymously.
Which means that if only one device knows where it is, you can calibrate, and if several know, you can even correct for mistakes.
If the system is precise enough, you only need to calibrate once in a while. Being at home/office, on the local wifi, once, could be enough.
Besides, nobody wants the GPS to go, but it's a nice alternative that can't be jammed by enemy forces and can be used for hiking, diving, etc.
I mean the exact position, down to a millimeter, when e.g. a photo sensor on a train passes past a LED mounted below the station platform. The LED's light is modulated so there can be no mistake, and its location is precisely known.
A meter precision is fine for what most people use GPS for. If the device is as precise as they say, you won't add much imprecision to the original calibration, so you will be in the right tunnel at the right time.
The US, the UE and China have wildly different approaches to many important topics, and the fact they are all affecting the entire world has the tendency to break political stale matches and balance things out.
It shows that diversity is a good thing, you end up having to compromise no matter how rightful you feel.
The problem is people keep trying to stamp the diversity out.
The model in the US is nominally to have few regulations limited to things like enforcing contracts and antitrust laws and pricing major externalities, then leave the rest of it to free market competition. That isn't compatible with a model where regulators are trying to run the economy, because then the regulators get captured by industry and thwart rather than protect competition, and competition can't save you from needing complicated rules if it is not present. And those kinds of complex competition-destroying regulations are showing up everywhere, including in the US.
Conversely, the model in the EU is to not care a lot about small businesses and just regulate the large ones. But that model isn't really compatible with free trade. You can't impose expensive regulations on domestic companies and then put them into competition with countries that don't do that and expect them to succeed. But people want to have their cake and eat it too. They want the expensive regulations but not the correspondingly higher prices, and then the stuff they buy gets made in China where the rules don't exist (or exist on paper but the government waives them in order to capture the market). If you want to have the rules without destroying domestic industry then you have to impose them on the manufacturers of imported products too. Which would actually help the US increase competition, because the regulations would then shackle global megacorps that want to sell into the EU but not smaller domestic US companies that don't. But then foreign-produced stuff sold in the EU would cost as much as domestically-produced stuff -- a boon to local industry but higher prices on local consumers, and apparently they're not willing to suffer the latter.
> The problem is people keep trying to stamp the diversity out.
I'm very cynical about this "diversity is our strength" stuff
In my opinion the problem is that society has been working hard to reduce "diversity" to mean different skin colors, genitals or sexual preferences, with a sprinkling of different cuisine. What most people refer to as diversity is very superficial
Diversity of ideas, diversity of politics, diversity of beliefs are still not very popular
The idea seems to be that the superficial diversity automatically produces the meaningful diversity, but I don't think that is true
Doesn't the US allow "diversity" by allowing different states to pass laws that their residence find important? I'm pretty sure CA has some specific right to repair laws.
Also, this (to me) is a strange use for the word diversity.
States and localities can pass their own laws but they can't remove the federal ones, and federal laws preempt state laws. Naturally large corporations then make a point to capture the federal regulators.
It can be slightly more complicated with things like CARB which has an explicit waiver in the Clean Air Act to enact its own standards and given how big it is it basically ends up setting de facto standards for the state (it’s one of the big complaints from Republican states).
A similar issue comes up around education although things are a bit more even there with Texas and Florida also using the size of their markets to set their version of education standards.
It "shouldn't" be a problem for the US to do that, because it's supposed to be minimizing regulatory overhead and promoting competition so its companies are globally competitive. Importing something from a country because they have a large labor market is a different thing than importing things from that country because your country imposes high regulatory overhead on domestic producers but not on foreign imports.
This also gets back to my point about the US increasingly failing at its ideal of not imposing high regulatory overhead.
I'm often guilty of missing mistakes in my own posts, but as a PSA: please proofread your posts, especially if using prediction on a phone.
You can edit your post if you do so soon after posting, and sometimes the meaning isn't lost (stale matches -> stalemates) but other times it (subjectively) is. For example I don't know what "rightful" should be here.
I always thought it would be a good idea to have a suggest spelling improvements on social media & forums. Gives a low-key way of improving things without wasting comment space and potentially saving embarrassment. But I’m sure it needs a good ux or otherwise will be abused
I agree. Stack overflow has/had something like this where users with at least N karma could make edits to others' posts. I believe that was done with an aim like what you've described, though of course it is also subject to some abuse.
ESL commenters are perfectly capable of learning to avoid and correct mistakes. In face, in written language some kinds of errors are more common in native speakers in my experience.
Probably a lot that we don't know about, because ChatGPT has better reasoning skills than most other systems out there, and we know reasoning is not really about the weights.
The trick is to make it look like an amazing opportunity, not something to fear about. The FOMO will be here, but hidden below enthusiasm, and the person will feel like they are actually lucky to have the opportunity.