Htmx, useful or bloat?

(You… do realize that htmx is just a javascript framework, right? You’re not avoiding anything, just bloating your site?)

Duh. What I mean to avoid JavaScript, I meant it doesn’t need to write it.

About bloated; that’s another discussion. So let’s agree to desagree for now

Okay; i’ll write

document.getElementById("buttonname").addEventListener("click", (e) => {
fetch("myformprocessor.php",{method: "post", body: new FormData(document.getElementById("myform")})
.then(data => data.json())
.then(data => { if (data['success'] == 1) { document.getElementById("emailnotice").classList.add("success"); }
});

and you add 14Kb worth of javascript to your load, and write whatever attributes you need to write into the HTML, and we’ll… call it a draw? cough

EDIT: As this has now been sharded off from the original thread, letme be clear for those wandering into this thread: I’m not saying that HTMX is always bloat. It’s bloat in the original thread’s case, where he simply wanted to AJAX a form and put up a success message.

Yes. I could agree with this. My bad I always think of the success of the project, hence the potential for growing.

Your code in htmx. I can achieve a more concise and declarative approach to form submission and response handling, i.e I can concentrate more and what I am trying to achieve, while minimizing, as much as, possible me writing JavaScript. Simplifying my code and improve the overall user experience.

By the way no json reponse, just html.

<form id="myform" hx-post="myformprocessor.php" hx-target="#emailnotice">
  <button id="buttonname" type="submit">Submit</button>
</form>

<div id="emailnotice"></div>

I mean, if you want to minimize, you’d just check the HTTP response code, but fair enough.

I… dont think you’re “improv(ing) the overall user experience”, but that’s an eye-of-the-beholder thing, i suppose. To me, that code is “simplified” to the point of being unintuitive, but i’m used to coding in Javascript.

Side note: For some reason Discus is marking all of the posts in this thread as a Solution to me… is that just me, or is everyone seeing that? (EDIT: No it’s not, Marc. It’s… confusingly decided I created the thread, so it’s giving me the OPTION of marking posts as the solution. derp.)

Have to like the fact they have this page on their website
HTMX sucks :biggrin:

I used HTMX recently with a python project alongside fastapi and jinja2. I liked it and found it very intuitive to use. Like Zensei, I also appreciated not having to write additional JS.

Stating the obvious, but I guess it depends on the project and making an informed decision.

In the case of the OP, it might be worth learning the vanilla JS approach first.

1 Like

Well thats always the case. I just struggle to find a justification for loading what amounts to 3 times your entire page codelength, and learn a new language structure that apparently very few people use, just to obfuscate 3 lines of javascript? (and yes, its obfuscating, because the library… is doing those lines of javascript anyway. It is a javascript library. It executes vanilla javascript.)

Hey, @rpg_digital, check this out.

Modern web applications in pure Python

I love it.

Build on solid foundations

FastHTML stands on the shoulders of giants:

ASGI
ASGI
HTMX
HTMX
HTTP
HTTP
HTML
HTML

1 Like