Live data from Hacker News

Htmx in a Nutshell

htmx.org

131–140 of 414 posts

Re: Htmx in a Nutshell

#131

Earlier quoted context omitted.

> as if this sort of thing doesn't exist in other languages and stacks It doesn't. For example in the Java world and in the last 10 years there were only two "frameworks". Just Spring and Oracle/Java EE Now two more have appeared (Quarkus and Micronaut) bringing the total number of frameworks to 4.

I'm not a java man but a quick google leads to a lot of "10 java frameworks you should know", "17 popular java frameworks", and a "list of java frameworks" on Wikipedia that's dozens long. Frontend wise it seems similar at a glance, in that you could use react for the last 10 years and be fine. Or you could jump from react to vue to svelte and make life hard for yourself.

I looked at some of the articles you mention and they are completely clueless

They include stuff like

- Hibernate - this is just an ORM

- JHipster - this is just opinionated Spring

- mybatis - again ORM

- Grails - > This is Groovy and not Java

- Play -> This is Scala primary

- Primefaces -> an implementation of Oracle/JavaEE

I think you get the idea. I am actually amazed at who is the target audience of this kind of blog posts.

Re: Htmx in a Nutshell

#132
post #113

howdy, I'm the creator of htmx, happy to talk about it

Hi, thanks for the libraries! When I started using them, one of the hardest parts was to actually have it imported and built with webpack, since the site focuses on cdn and webpack example is really brief. Same goes for hyperscript Do you see cdn as a preferred way of usage?

unfortunately I don't know webpack really well, although I'd love docs contributions on it if the existing docs aren't good

Re: Htmx in a Nutshell

#133

howdy, I'm the creator of htmx, happy to talk about it

You have mentioned here and in other places that you use HTMX + HyperScript in production. Curious what that looks like, is it part of consulting, a side business, a day job ?

consulting as a side gig of my day job, which is a CS prof

Re: Htmx in a Nutshell

#134
post #114

howdy, I'm the creator of htmx, happy to talk about it

How does error handling work? If I try to replace the content of some div with a reply I get using htmx, but the request fails or times out etc., what content is then put into the div? What if the reply is not valid HTML? Sorry for the newb and lazy questions.

htmx doesn't do anything on an error by default, but you can override this behavior using the extensive event system it has:

https://htmx.org/events/#htmx:responseError

Re: Htmx in a Nutshell

#136
Very nice, but this:

> Now any HTTP verb, not just GET and POST, can be used

requires care. I'm assuming HTMX is just a JS library that attaches all these behaviors to HTML. That's fine, as that won't change anything as far as cross-site scripting goes. It's just that if this were coded in the browser, and the responses to these requests made available to the page, then bad things would happen.

Also regarding this:

> Note that when you are using htmx, on the server side you typically respond with HTML, not JSON. This keeps you firmly within the original web programming model, using Hypertext As The Engine Of Application State without even needing to really understand that concept.

it's much easier to write server-side APIs that produce JSON and static HTML + JS that consumes it than it is to generate HTML (and then also JSON for non-browser apps).

On the whole I like this a lot.

Re: Htmx in a Nutshell

#138
Related:

Moving from React to htmx - https://news.ycombinator.com/item?id=33218439 - Oct 2022 (315 comments)

An SPA Alternative - https://news.ycombinator.com/item?id=32148253 - July 2022 (138 comments)

Reimagining front-end web development with htmx and hyperscript - https://news.ycombinator.com/item?id=31949621 - July 2022 (207 comments)

Building a fullstack app with Flask and Htmx - https://news.ycombinator.com/item?id=30843275 - March 2022 (140 comments)

The Renaissance of server side rendering with Alpine and HTMX - https://news.ycombinator.com/item?id=30577181 - March 2022 (9 comments)

How a hypermedia approach can address usability concerns with multi-page apps - https://news.ycombinator.com/item?id=29693571 - Dec 2021 (128 comments)

Building a simple room-based chat application in Nim (using HTMX) - https://news.ycombinator.com/item?id=29594763 - Dec 2021 (28 comments)

Django, HTMX and Alpine.js: Modern websites, JavaScript optional - https://news.ycombinator.com/item?id=29319034 - Nov 2021 (274 comments)

Htmx 1.2.0 Release - https://news.ycombinator.com/item?id=26128229 - Feb 2021 (25 comments)

Htmx 1.0.0 Release - https://news.ycombinator.com/item?id=25232719 - Nov 2020 (58 comments)

Htmx – high power tools for HTML - https://news.ycombinator.com/item?id=23330881 - May 2020 (166 comments)

Re: Htmx in a Nutshell

#139
post #97

Earlier quoted context omitted.

Replying to myself: I guess the main point of this library is to use HTML as the protocol payload between serve and client, instead of JSON. I can see the benefit of doing that, although I have a bone to pick with the condemnation of all data APIs because JSON is awful. Protocol buffers, for example, are trivially forward and backward compatible and mostly self-describing. Also if you build stuff on top of hypermedia…

You can use the swap data attribute to update several fragments (imagine a saved icon) in several places declaratively.Then you can get rid of almost all your js code. The price to pay for this is it does not work offline. For quickly prototyping and app it is very fast.

> You can use the swap data attribute to update several fragments (imagine a saved icon) in several places declaratively.

Yeah, but why? The javascript snippet to accomplish the same is absolutely trivial and avoids a dependency.

> The price to pay for this is it does not work offline. For quickly prototyping and app it is very fast.

The true price is that you've now rewritten your HTML code in a non-standard DSL and are forever dependent on a third party library, and all that to accomplish a goal that seems entirely aesthetic to me.

Re: Htmx in a Nutshell

#140

Earlier quoted context omitted.

> as if this sort of thing doesn't exist in other languages and stacks It doesn't. For example in the Java world and in the last 10 years there were only two "frameworks". Just Spring and Oracle/Java EE Now two more have appeared (Quarkus and Micronaut) bringing the total number of frameworks to 4.

Sure, if you ignore Dropwizard and tons of other less popular java frameworks out there.

Maybe I am missing something but Dropwizard is not a framework on its own but instead of collection of external and independently developed libraries
Post reply on HN