Live data from Hacker News

Htmx – high power tools for HTML

htmx.org

61–70 of 175 posts

Re: Htmx – high power tools for HTML

#61

Earlier quoted context omitted.

I wanted the freedom to completely reimplement things and drop ideas that didn't work out in intercooler I also wanted to stress that htmx isn't just another javascript library, competing with react and the rest. It is focused on HTML and extending HTML to make it a powerful and complete hypertext. I think that the name htmx captures that idea pretty well.

What ideas do you think didn't work out? Btw, I'm currently a very happy user of intercooler. Thanks for the awesome lib.

I think the implicit dependency system is a good example that ended up confusing people as much as it helped: http://intercoolerjs.org/docs.html#dependencies

The fact that intercooler didn't have an extension mechanism meant I had to heap a lot of stuff into the core (e.g. ic-action) that was interesting and useful, but made the code base messy and unfocused.

htmx has an extension mechanism, so you can pull in stuff like this (or write your own extension):

https://htmx.org/extensions/

that will take pressure off me to keep adding stuff to htmx and simply add more extensions.

The dependencies idea from intercooler, for example, ended up as this extension:

https://htmx.org/extensions/path-deps/

Re: Htmx – high power tools for HTML

#62

Earlier quoted context omitted.

looks like there's a bug in the json-enc extension: it's relying on the test mock which has a requestHeaders property that a real xhr won't. so the tests passed but it doesn't work irl... good catch! want to submit a pull request fix?

Sure =D Done! Also this extension API is pretty straightforward, the element reference and parameters are right in the args so it's an easy mapping to GraphQL query strings from there. Awesome! I was able to get a minimal version working using just this (with json-enc extension patch): " /> Pretty cool

i'd love a graphql extension for the next release, if you are interested

Re: Htmx – high power tools for HTML

#63
How do you test applications written with Htmx? Does it all need to be ui test harness (running in a browser), or can you unit test components somehow?

I'm happy you noted the test coverage for the library itself is reaching your standards. That's a great sign.

Re: Htmx – high power tools for HTML

#64

Earlier quoted context omitted.

I'm not dogmatic about it. Some validation has to be done on the server side (e.g. unique emails) and any validation has to be redone on the server anyway since the client side isn't a trusted computing environment, but I can see doing both.

Ahh got it, yeah in this case that makes a ton of sense. No way to know with emails about uniqueness constraints until it hits the backend anyways. I've been playing around with local demo, is it possible through extensions to make a wrapper that can perhaps compose GraphQL query inputs from forms?

Front-end validations should always be viewed as a suggestion. the server is the real gatekeeper

Re: Htmx – high power tools for HTML

#65

Earlier quoted context omitted.

Sure =D Done! Also this extension API is pretty straightforward, the element reference and parameters are right in the args so it's an easy mapping to GraphQL query strings from there. Awesome! I was able to get a minimal version working using just this (with json-enc extension patch): " /> Pretty cool

i'd love a graphql extension for the next release, if you are interested

Yeah, definitely game to help out there =)

Re: Htmx – high power tools for HTML

#66
post #63

How do you test applications written with Htmx? Does it all need to be ui test harness (running in a browser), or can you unit test components somehow? I'm happy you noted the test coverage for the library itself is reaching your standards. That's a great sign.

You can use the same technique I use in my tests: sinon.js has FakeServer that mocks AJAX calls.

I think I'd look into a headless chrome setup against my real server if I was doing a large app.

Re: Htmx – high power tools for HTML

#67

Earlier quoted context omitted.

Ahh got it, yeah in this case that makes a ton of sense. No way to know with emails about uniqueness constraints until it hits the backend anyways. I've been playing around with local demo, is it possible through extensions to make a wrapper that can perhaps compose GraphQL query inputs from forms?

Front-end validations should always be viewed as a suggestion. the server is the real gatekeeper

I should have rephrased it haha, I more meant the act of sending each set of keystrokes validation as a server-side request. No doubt that the backend is going to be the ultimate judge when "submit" is pressed.

Re: Htmx – high power tools for HTML

#69
This looks amazing -- seems like you can accomplish a significant amount of what constitutes front-end work these days with htmx. The examples are compelling:

https://htmx.org/examples/

There is a slight deal-breaker for me. Much of the functionality revolves around hx-swap'ing i.e. writing the contents of a response as HTML into/around tags. This requires the server-side to return HTML instead of JSON. From the docs:

"Note that when you are using htmx, on the server side you 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."

I would love to use this with existing REST backends, but most are only able to return JSON. How does one use this for AJAX without rewriting existing backends?

Re: Htmx – high power tools for HTML

#70
post #69

This looks amazing -- seems like you can accomplish a significant amount of what constitutes front-end work these days with htmx. The examples are compelling: https://htmx.org/examples/ There is a slight deal-breaker for me. Much of the functionality revolves around hx-swap'ing i.e. writing the contents of a response as HTML into/around tags. This requires the server-side to return HTML instead of JSON. From the docs…

You could check out the client side templates extension:

https://htmx.org/extensions/client-side-templates/

Post reply on HN