Readit News logoReadit News
simonbarker87 · a year ago
One of the happiest days of coding in the last 10 years for me happened in September last year when I added htmx to an internal self serve web app I develop for our company. With the addition of maybe 5 htmx attributes I was able to delete about 500 lines of client side JS.

The app is now chock full of htmx interactions and has very little client side JS for the size of the app and it’s a joy to work on.

Without htmx I would not be able to turn around features as quickly as I do for the wider team so thank you, thank you, thank you.

I’ve been in web dev for 20 years and this feels like what we should have made all along.

The one area I would like to see some development is the file upload experience, I’ve had to do something a bit weird to get htmx and dropzone playing nice.

niutech · a year ago
You deleted 500 lines of JS and added 44KB of (minified) HTMX. Better use HTMZ, which is only 166 bytes (sic!) and provides most of the interactivity: https://leanrada.com/htmz/
jordiburgos · a year ago
The problem is not the download size. The problem is the amount of code to maintain.
cztomsik · a year ago
can you comment on what those 500 lines actually were? react+redux?
simonbarker87 · a year ago
It was all normal JS code to handle a complicated form we have on a customer facing portal page. By moving to htmx I was able to rely on the server side to handle basically everything with only a small addition of code to what it was already doing.
gofreddygo · a year ago
can anyone comment on what 500 lines of react+redux actually do ?
smegsicle · a year ago
all htmx does is replace divs on the page, so probably just code that did that
renegade-otter · a year ago
I would say, this and the CSS grid/flex system has made web development almost... enjoyable.
recursivedoubts · a year ago
hey folks, i'm the creator of htmx

this isn't much of a feature upgrade, but we took the opportunity to clean up a few things and drop IE support, which will help us slim down the library over time

hopefully it's an easy upgrade for most htmx users, upgrade guide is here:

https://htmx.org/migration-guide-htmx-1/

happy to answer any questions

jpgvm · a year ago
As someone that has long since soured on frontend things despite having tried everything from the start - mootools, jQuery, backbone.js, SproutCore, Ember, React, Vue, etc.

I genuinely think htmx is the only one I have liked even after I built something substantial in it.

To me that is big, to be able to walk away from a significant amount of time with something and say "yeah! I want to use that again!" instead of some variant of "it's the least bad option" is both rare and cherished so thanks for all the hard work.

recursivedoubts · a year ago
:) glad to hear it, definitely appeals to some people (and disgusts some other people!)
w4 · a year ago
Not a question, but I just wanted to say that HTMX is a joy to work. I’m using it in production to slowly replace VueJS wherever full SPA interactions aren’t needed, and it has made development so much simpler. HTMX is such a breath of fresh air from the over-engineered jenga tower that web dev has evolved into over the past decade.

Thank you!

synergy20 · a year ago
aren't mixing vuejs and htmx making things more complicated?
recursivedoubts · a year ago
:) great to hear
gaganyaan · a year ago
Are there any efforts to push functionality like this into the HTML standard? It would be nice if htmx eventually became unnecessary as browsers implemented it, and the work you're doing with proving it out in the wild seems like a crucial part of that.
recursivedoubts · a year ago
yes, there are, alex petros, an htmx maintainer, gave a talk at Big Sky Dev Con on the shortest path to htmx-like functionality in HTML here:

https://www.youtube.com/watch?v=inRB6ull5WQ

we are talking w/the chrome developers about these ideas, i'm cautiously optimistic

niutech · a year ago
HTML already allows a lot of HTMX functionality with just 166 bytes of JS glue code, see HTMZ: https://leanrada.com/htmz

You can make tabs, accordions, carousels, modals, popovers and even Pure HTML Out-Of-Order Streaming (PHOOOS) using only HTML & CSS: https://kodus.pl

gws · a year ago
No question but I wanted to say, I was pulling my hair out trying to figure out which js framework was less of an overkill, and finding htmx was pure joy
recursivedoubts · a year ago
:) that's great to hear, i hope you find it useful
bun_terminator · a year ago
Thank you. htmx has me (a c++ dev) back in the web game. I can finally build entire web frontends without a single line of explicit js.
recursivedoubts · a year ago
really great to hear, i love that htmx helps folks that have been knocked out of web development get back into it
logankeenan · a year ago
Have you considered replacing xhr with fetch? I believe it would allow htmx to be used in even more places. Fetch can be hijacked so returning data to the htmx framework isn't limited to the network. You could "run" a server in the browser or have a native app render HTML as well.

Perhaps, there's already a good way to hijack xhr that I'm unaware of too.

Edit: Relevant link: https://logankeenan.com/posts/client-side-server-with-rust-a...

recursivedoubts · a year ago
yeah, looked at it, unfortunately fetch() and xhr have a non-intersecting set of features (in particular, upload progress for xhr) so we decided not to touch it

i may restructure the internals to allow for mocking out responses using events, it comes up, especially w/ extensions

aquariusDue · a year ago
I'll join the others in praise of HTMX, it's a joy adding dynamic functionality to any website now. Thank you!
recursivedoubts · a year ago
:) thank you i hope you continue to find htmx useful
knighthack · a year ago
Hey Carson! I'm using HTMX on quite a number of internal tools. It's completely revolutioned the way we've done things, especially coupled with Django. Extremely grateful for your work - you're a net positive for humanity.
droptablemain · a year ago
He's the creator, but not the CEO. That title belongs to me...and you.
recursivedoubts · a year ago
DLA · a year ago
Huge congrats on the major number release. HTMX is simply wonderful. Using it for a major project as we speak!
jack_riminton · a year ago
Would love to hear more about how you’re using it
nickpeterson · a year ago
Another, “I really like htmx” comment, currently using it for an internal corporate webapp, it’s great.
dpe82 · a year ago
Thanks for all your hard work; htmx is a breath of fresh air and an escape from the morass of needless complexity.

My only question: how can I get a set of those sweet sweet floppy disks?

recursivedoubts · a year ago
working on it, need to see if the disk guy will dropship
lenkite · a year ago
What is your opinion on https://github.com/unpoly/unpoly as a competitor ?
recursivedoubts · a year ago
unpoly is a great library that sets the standard for progressive enhancement

i often recommend it for people that want a more "batteries included" hypermedia-oriented library

emmanueloga_ · a year ago
Oddly specific. Why implementing "forEach" and "toArray" instead of using the functions from Array.prototype? [1] I can see `Array.from` used elsewhere on the code.

---

1: https://github.com/bigskysoftware/htmx/blob/master/src/htmx....

recursivedoubts · a year ago
IE support, haven't removed some of the shims, planning on doing so over time
niutech · a year ago
As for slimming down over time, HTMX 1.0 was 26KB minified, now version 2.0 is 48KB minified. Why has it blown up by 184%, when it dropped IE support? Why don't keep it lightweight? Compare it with e.g. Petite Vue, which is 16KB minified.
recursivedoubts · a year ago
htmx 1.9.12 was 44kb:

https://bundlephobia.com/package/htmx.org@1.9.12

and 2.0.0 was 45.3:

https://bundlephobia.com/package/htmx.org@2.0.0-beta4

i think that the better web components support blew is up a little. there is a reasonable amount of fat we can cut around IE support that is still in there, planning on doing so over the next few months & slowly

17ms over emerging 4G (and hopefully cached forever after that) doesn't freak me out too much

mrinterweb · a year ago
Do the docs https://htmx.org/docs/ reflect 2.0 or 1.x?
recursivedoubts · a year ago
2.x
llmblockchain · a year ago
Does this release have head-support built in or still requires an extension? I thought 2.0 was going to release with head support...
recursivedoubts · a year ago
we went back and forth on it but ultimately concluded that it bloated the core too much so we kept it as an extension
stereo · a year ago
Your front page still says “IE11 compatible”.
jmorgan · a year ago
Thank you for building htmx!
Devasta · a year ago
HTMX is like a glimpse into the road not taken, where HTML is the main language of the web instead of JS. Sometimes the grass really is greener on the other side, and I hope as an industry we make the switch.
oblio · a year ago
My cynical take: this is by design. Those web committees are staffed by companies that each have their non-web platform they're pushing (or were, until it died, see Microsoft), so even the most well meaning members are somehow contorted into compromises that make the web as a platform a bad technical choice in terms of actual design, but the best one in terms of flexibility and of course ubiquity.

It's completely stupid HTML, by default, doesn't have basic controls found in EVERY UI toolkit since circa 1980. The standard examples being ListView and TreeView.

jwells89 · a year ago
> It's completely stupid HTML, by default, doesn't have basic controls found in EVERY UI toolkit since circa 1980. The standard examples being ListView and TreeView.

This is one of my greatest frustrations with the web as a platform. These controls are so basic they should just be there, eliminating the need to sift through dozens of third-party implementations all with wildly varying feature sets, performance profiles, framework compatibility, levels of upkeep, etc to find one that works for your project.

maigret · a year ago
Don’t attribute to malice… Many people working on frontend came from application or backend development and preferred the JavaScript model to a more declarative one. Not understanding enough the document context that drives the web. This makes everything more fragile and slow but hey “functionality” wins over everything else in todays world.
bryan_w · a year ago
It is possible for normal everyday people to make contributions to the standards. I'm sure if you created a patch that showed these things working in firefox/webkit/chrome and wrote up a proposal and sent it to the correct listserv, you would at least have something more than baseless conspiracy to be mad about
kyrra · a year ago
I believe he makes some good arguments that we really still need both, but HTML could be more powerful and allow for less JS.

This is a good essay on the topic: https://htmx.org/essays/when-to-use-hypermedia/

Definitely one place htmx can be abused is oob-swap: https://htmx.org/attributes/hx-swap-oob/, which allows any given HTMX request to replace any part of the page. It sort of destroys the concept of locality of concern that HTMX pushes for.

qw · a year ago
One example of this is the lack of an include-tag that could fetch a fragment from the server (useful for headers/footers). Developers have wanted it for decades and have been forced to reproduce the functionality themselves using frames and/or javascript.
Devasta · a year ago
https://www.w3.org/TR/xinclude/

The W3C specced out such a tag nearly 20 years ago, but because the browser devs are terrified of all things XML it was never implemented.

kyrra · a year ago
I thought the 2.0.0 release was a bit of a joke from the BigSkyDev conference, as he was doing stuff like this:

https://twitter.com/htmx_org/status/1799661735781261592

There's even some sweet ascii art on the disk: https://twitter.com/jcs224/status/1799586838161621339

Great to see the continued love of this framework. (don't throw anything at me)

recursivedoubts · a year ago
released exclusively on floppy disk for the first week! :)
recursivedoubts · a year ago
@dang, i know there is an htmx filter on HN due to so many posts, but it'd be nice if this one could go to the top, it's a major release
jack_riminton · a year ago
+1, if there’s so many posts then there’s clearly pent up demand to talk about it
wruza · a year ago
Htmx users, can you please share your backend stacks and approaches? Me specifically interested in templaters for node (+ts) and your thoughts on endpoint management, but all ideas are welcome I guess.
fprotthetarball · a year ago
My backend for a simple web application I'm working on is entirely in Rust. Highlights:

- axum: web application framework - https://github.com/tokio-rs/axum

- axum-htmx: axum extractors, responders, guards for htmx - https://github.com/robertwayne/axum-htmx

- rusqlite: SQLite bindings - https://github.com/rusqlite/rusqlite

- maud: HTML templating as a macro - https://maud.lambda.xyz

The way maud lets you compose markup works very nicely with htmx. The HX-Request header lets you know if the request is coming from htmx or if it is a regular request. You either call the top-level function if it's a regular request to get the entire page rendered, or call a subset of functions to get the appropriate partial rendered if it's an htmx request.

It's also nice to easily have tests for the rendered pages. My unit tests cover verification of the rendered HTML, too.

brunoqc · a year ago
Do you use something like cargo-watch for "hot reload"?
pondidum · a year ago
Go: go templates and fiber for http serving. I have a mini framework for adding some structure to the templates (folder per feature: contains controller, templates, etc, and some naming conventions)
jjude · a year ago
I too use go + fiber + htmx.

> mini framework for adding some structure to the templates

Would be good to read little more about this mini-framework

Art9681 · a year ago
This is my stack as well and it works great.
amanzi · a year ago
Django user here. HTMX fits in perfectly with the Django templating system. A fairly common approach is to use the same view but check for the HTMX header and then return a template file with the specific bit of HTML being swapped. There's also work in the Django space to be able to return parts of a template based on the request, which will suit HTMX perfectly too.
magnusstaberg · a year ago
We use Django with https://htpy.dev/ as templating system.

Dead Comment

wruza · a year ago
Well, as I expected, templating is the hardest part of migrating to htmx on nodejs.

After reviewing few templaters/etc (handlebars, ejs, lit-html, virtual-dom) and few abstractions (html``, just ``, h()), barely anything seems too easy and too freedom-y. Arcane syntaxes, high character noise (ejs, lit, js), lack of typing (all non-`` based), trivial screw ups (virtual-dom, handlebars), experimental status (lit ssr). Sigh.

unsupp0rted · a year ago
This was my experience as well. No great template generator on the node side.

I use PUG. I don’t like to close HTML tags. This cuts 30% of the visual bloat out of my templates.

wry_discontent · a year ago
I usually use Clojure, Huff for html templating, and whatever DB libs. Pretty much whatever is in Biff[1] is what I want to use.

[1] https://biffweb.com/

prisenco · a year ago
Go with fasttemplate.

Most people prefer templ but I don't like logic in templates, I just want to parse values. I keep different states in different template files.

Each template file is a portion of a full page which makes it easy to create an endpoint that pulls the partial with the latest values. HTMX can then hit that endpoint to load or refresh values.

Endpoints are usually

    domain/page/partial
so if I'm on a configuration page at

    example.com/config
then the endpoint for the privacy settings partial would be

    example.com/config/privacy
Going directly there in a browser would get a 404 because I check for the HX-Request header.

Endpoint handlers return a processed template with the current state. I use those functions to both compose the full page on the backend, and to build the output for the partial endpoint.

I don't automatically expose all partials. I add endpoints as I need them. This is probably more idiomatically Go than anything to do with htmx.

jsnelgro · a year ago
Htmx + Kotlin with ktor and the html dsl was really fun to play with on a personal project. Static typing, autocomplete and a full-fledged programming language available to use in your html markup is a game changer. I was structuring my endpoints as pairs of "data" and "render", where the render endpoint just reused the function for the date endpoint.
PyWoody · a year ago
Flask+SQLite+TailwindCSS.

It's basically cheating. The setup is dead-simple to operate.

jononor · a year ago
What do you use for templating/HTML generation?
SwiftyBug · a year ago
Go + Templ + htmx

Templ is great when you need to separate reusable components.

simonbarker87 · a year ago
NestJS with Handlebars templates. I don’t love Handlebars but I have past experience with it so was the most pragmatic choice.

I’m interested in trying EdgeJS as a templating alternative to HB but haven’t got round to it yet.

I’ve added a NestJS error handler that looks to see if the request came from an htmx request and then serve the error response as html, if not then it sends back json since I do have json api end points as well in the back end.

otherflavors · a year ago
perl + Template Toolkit (using the underdocumented support for the fragment pattern with EXPOSE_BLOCKS), before finding htmx we used Jemplate, which let you compile Template Toolkit templates into Javascript functions
Raticus79 · a year ago
I'll be trying things out with FastAPI and Jinja templating
swlkr · a year ago
rust and ryde (my own framework on top of axum and rusqlite)
RobotCoder · a year ago
My hot take: We initially used this library to allow us to iterate faster. But its is a pain once you reach a certain point, where it doesn't make sense to have this type of logic in HTML. I especially don't like how this library does error handling. I feel like this is the new jQuery. There is better way to represent interaction logic with open JS standards like Web Components.

Deleted Comment

jph00 · a year ago
I just want to take advantage of this news to say: I love HTMX so much! :D It makes web development fun again. I can still use all the fancy js libs I want -- but my main logic lives on the server, using plain HTTP and HTML. Really clear and simple.