←back to thread

Less Htmx Is More

(unplannedobsolescence.com)
169 points fanf2 | 1 comments | | HN request time: 0s | source
Show context
chabska ◴[] No.43619770[source]
> In practice, this is virtually impossible to get right

Somehow every other JS frontend framework manages to hook into the History API just fine?

replies(5): >>43619808 #>>43619818 #>>43619832 #>>43619991 #>>43621102 #
ForHackernews ◴[] No.43619832[source]
What? They all butcher it. On a weekly basis I make the the mistake of clicking some link to a site and find I can't hit the back button to escape. Maybe this is technically the site developers' fault, not the library devs, but it's a lousy experience for users.
replies(2): >>43619865 #>>43619918 #
philipwhiuk ◴[] No.43619865[source]
Sometimes it's definitely deliberate
replies(1): >>43620011 #
ffsm8 ◴[] No.43620011[source]
Heh ,I actually once added a bug like that too. Angular has "redirect" routes (path matches with redirect to a new path).

I didn't realize that this will make the back button effective unusable, because the redirected url will still be in the history unless you manually redirect with a bare component. Hence whenever someone used back, the redirect pushed them back to the route they just left. I just used it as I came from a backend perspective, where redirects are fine as there is a delay between the request and the redirect, giving the user the time to just double press back... Obviously not so with a JS redirect.

I believe that continues to be an angular Anti-Feature to date.(Just checked, they still have it in their docs - without the ability to surpress the redirected history entry as far as I can see)

replies(2): >>43620717 #>>43621109 #
chuckadams ◴[] No.43620717[source]
It sounds like something you'd use for a POST route that served up html instead of JSON (weird for an app to do these days but it still happens). redirect-after-post is as old as the web (or at least the POST verb) and it actually _enhances_ the utility of the back button by removing the annoying prompt about re-posting.
replies(1): >>43621919 #
1. ffsm8 ◴[] No.43621919[source]
There are countless usecases for redirects.

A few examples of the top of my head:

when urls have changed,

when a resource/entity has been deleted,

when you wish to provide a unified entrypoint that sends users to another url so that you can easily change the redirection target in the future (i.e. redirecting a / to a /entities, so youre but blocking the / path if you want to add a homepage/landing page later)

I don't think I'd help with posts though. They do indeed usually send back a redirect - but the post is likely still in the history unless the website send it as AJAX/without a history entry (basically via JS fetch() instead of form action=)