Live data from Hacker News

Htmx in a Nutshell

htmx.org

321–330 of 414 posts

Re: Htmx in a Nutshell

#321

slightly off topic but I've been having the best time getting back into rails version 7. (I left the rails world back in 2014) This tutorial https://www.hotrails.dev/turbo-rails/css-ruby-on-rails makes clean views with auto magical css that just works. It is amazing.

Been looking for an excuse to get started with Rails 7 & hotwire.

Re: Htmx in a Nutshell

#322
post #94

Earlier quoted context omitted.

Is the argument here that there are too many JS frameworks, or that the complexity of the frameworks themselves tends to grow over time? If the former, totally agree. If the latter, Java frameworks are plenty complicated. Also not sure how you've missed a lot of other frameworks; Spring and J2EE are certainly not the only ones that have been around for 10+ years. Dropwizard, Vert.x, akka-http, GWT, Play... just to na…

The argument is that I could learn Spring in 2002, find a Job then I could learn Spring in 2008 and find a job and then I could learn Spring in 2013 and find a job and then learn Spring in 2018 and find a job and then learn Spring in 2023 and find a job. Spring IS complex, but you learn it once and you are done with it.

Or learn Cobol in 1965, find a job. Learn Cobol in 2022, find a job. Or Fortran - which I started using in 1983. Or C# (2000 for me)

I think the key distinction is that these languages and libraries evolve over time.

Re: Htmx in a Nutshell

#323
post #3

I am burnt out (but recovering!) with web dev and htmx is what I am using for my project. Django, DRF, Postgres, tailwind and HTMX. I am so tired of all the front end frameworks and all the complexity that gets added. At some point I think you need it and you get returns from it but hearing more people in the industry recognize and talk about how JS everything isn't always the answer gives me hope. I like what HTMX h…

How do you integrate tailwind and django? As far as I know (which isn't very much), tailwind encourages the use of "components" which comes very naturally with other frontend frameworks. But with django, do you put each component into a template, like `` and `{% include "button.html" %}` when you use a button?

Re: Htmx in a Nutshell

#324
post #160
post #101

Earlier quoted context omitted.

Yeah, that I understand. I am not a huge fan of sending JSON that's not backwards compatible. Sending HTML is probably a good choice for some applications, but that was already well supported 20 years ago. Why is htmx better than one line of javascript saying `onload = function() { e.innerHTML = response.body` } ?

In practice you don't want to just swap the content 100% of the time. Appending to the current content is quite common too, as is deleting from it. You sometimes need to touch other elements too, or maybe show a progress spinner. Or perhaps push a URL to the navigation history. Htmx provides a batteries-included data-driven experience. It is a means to avoid having to write dozens of slightly different variants of th…

But all of those things are trivial. Are we going to next get a library that lets you declaratively specify string operations and integer multiplication? Why not write a dozen variants of 5-10 lines of readable Javascript? What's the problem? It's maintainable, fast and every other developer will immediately understand it.

Re: Htmx in a Nutshell

#325
post #147

Earlier quoted context omitted.

Yeah, but why? Why is it better to remember a bunch of attributes than to remember 3-4 javascript functions?

It's pretty clear that TFA means that this is better because that's how HTML should have been, in their opinion. Is it better? Well, I think so. Practically speaking, for example, if you use NoScript or something like that, it kind of would be if you could block scripts but not HTMX. Also practically speaking the cognitive load of HTMX should be lower than the cognitive load of JS (especially for beginners). More gen…

But if you disable JavaScript, then htmx won't work either, right?

And how is it lower cognitive load? You have to learn JavaScript, but now you also have to learn htmx. I don't call that a win. Code is read by a lot more people than wrote it. It's not great if you constantly have to be learning some flavor-of-the-week framework. (No problem learning new things where it's warranted, but this isn't even interesting, it's just a DSL.)

Re: Htmx in a Nutshell

#326
post #145

Earlier quoted context omitted.

This idea used to be called microformats. The premise was that you send an HTML snippet, and all the semantic attributes plus a protocol definition will let you parse it as either data or a part of the UX. It's self-documenting in the sense that, if you do it right, the snippet has clear semantic meaning. However, it's not backward and forward compatible as either UI or data, because that was never an explicit goal o…

Um, 'parsing...data out of an HTML microformat' sounds like a fancy way and obscure way of saying 'the browser renders HTML, something it has been optimized to the gills for'. > Parsing a protobuf is probably at least 10x faster Faster than a browser rendering HTML? That would be quite a feat.

Yes, I am implicitly assuming that eventually someone will connect to it as an API, not just to directly render the HTML but to machine-process it.

Re: Htmx in a Nutshell

#327

Earlier quoted context omitted.

After going through a fever swamp project involving React, I am definitely in the camp of getting back to basics.

Wait till you end up on a fever swamp project involving templated HTML generation. Or even a fever swamp project involving jQuery.

I’ve built those sorts of apps for 20+ years. For me, the Rails / Flask type approach is much easier to work with.

Re: Htmx in a Nutshell

#328
post #325

Earlier quoted context omitted.

It's pretty clear that TFA means that this is better because that's how HTML should have been, in their opinion. Is it better? Well, I think so. Practically speaking, for example, if you use NoScript or something like that, it kind of would be if you could block scripts but not HTMX. Also practically speaking the cognitive load of HTMX should be lower than the cognitive load of JS (especially for beginners). More gen…

But if you disable JavaScript, then htmx won't work either, right? And how is it lower cognitive load? You have to learn JavaScript, but now you also have to learn htmx. I don't call that a win. Code is read by a lot more people than wrote it. It's not great if you constantly have to be learning some flavor-of-the-week framework. (No problem learning new things where it's warranted, but this isn't even interesting, i…

> But if you disable JavaScript, then htmx won't work either, right?

It would work if either HTMX became standardized and implemented by the browser, or if I could allow HTMX (the JS) and not other scripts [selectively].

Re: Htmx in a Nutshell

#329
post #124

Earlier quoted context omitted.

We already did in favor of TypeScript.

Typescript is a bandaid. We need improved DOM access for web assembly, followed by a new icon in the URL bar that indicates you're on a "legacy" site if it's using javascript (my vote is for a cute snail emoji)

We should make more bandaids like this, taking over big chunks of the programming world.
Post reply on HN