HTMX and Flask is really nice!

Been doing a small Flask project (mostly a CRUD site) and stumbled upon HTMX:

[https://htmx.org/](https://htmx.org/)

Basically, it's a bunch of magic Javascript so that you don't need to write any javascript! Full-CRUD and not a single line of my own JS. I couldn't be happier! It uses attributes embedded within HTML to super-power the HTML automagically. Works great with Jinja templating.

Not writing Javascript makes me happy, and I hope sharing this can make someone else happy too.

edit:

Since we're talking about javascript, I cannot stop myself from sharing my favorite Javascript-related meme:

https://preview.redd.it/zuknesooegf61.png?width=500&format=png&auto=webp&s=392616e6d7fcd24b7b8a1bf1c5d733af1fbf258d

3 thoughts on “HTMX and Flask is really nice!”

  1. Yep, it’s a really neat little library.

    But I feel like returning HTML fragments from certain routes is a bit iffy. I wouldn’t go so far as to call it an anti-pattern but I’ve had my fair share of burns in the past with that kind of approach. Sometimes you want to reuse a route but if the route returns HTML fragments instead of structured data like JSON, there’s a good chance that the returned HTML just won’t fit the surrounding HTML in terms of styling or structure. At that point you’ll have to work with query parameters that control how the returned HTML is rendered or completely different routes that almost do the same thing which can get messy.

    My advice: use with caution and only in small projects.

    Reply
  2. Had a quick squizz at HTMX — I am a complete noob to web dev – client side or other….Have tried my hands at JS – and yep never been able to wrap my head around it totally… Flask on the other hand – is quite enjoyable.

    whilst client side JS is a pain in the buttox….I doubt whether something line HTMX would solve that for a noob as myself – cos for most when learning…most content focusses on JS and HTML client side rendering…..

    I guess for more experienced devs HTMX would make great sense becos they already know basic JS and just need to spin up something quickly.

    With the rise of Vanilla JS as a standard in coding – would HTMX survive that onslaught?

    Reply

Leave a Comment