HTMX is a JavaScript library that essentially extends HTML and allows you to send AJAX requests (and handle responses + update the UI) without writing any JavaScript code. It's amazing!
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
So I recently released a brand new course, "HTMX - The Practical Guide". That's a course I actually didn't plan to create, because I got plenty of work to do with an ongoing Next.js course update and an ongoing Angular course update, and both updates will be amazing. I'm working on them, but they will still take some time. I get some other work and some other course related work as well. So HTMX was originally not a topic I
planned on covering with a course, but then I worked with HTMX quite a bit over the last couple of months. And I have to say, it's really an amazing JavaScript library. And you might, of course, wonder if you haven't heard about HTMX, do we really need another library? What does it do? What the others don't? The answer is HTMX helps you avoid writing front-end JavaScript code.
You can still use it with front-end JavaScript code, and I do cover that in the course as well, but you don't have to. And at least in my experience, you often end up with websites, with web applications that have a way simpler front-end code structure than you would have with React and so on. Now, I'm also not saying that it's better than React, that it should always be used instead of React.
Instead, both are amazing libraries. And of course, the same is true for Angular and so on. But for, at least in my experience, quite a few web applications and websites, HTMX might be the simpler solution, to be honest. Now, what exactly is HTMX though? What does it do? How does it work? As the name suggests, the idea is essentially that it extends the HTML markup language.
It extends it by giving you a bunch of new attributes, which you can add to HTML elements. Now, what do these attributes do though? Well, in the end, they deal with sending AJAX requests. So, behind-the requests from the front-end to some back-end. And they, or HTMX as a library, then also deals with the response that's sent back.
And HTMX makes sure that your front-end UI, your DOM, is updated with that response data. Though that data part is now also special and interesting. Because the idea with HTMX is that, unlike with React or Angular and so on, you're not exchanging JSON data between the front-end and the back-end. But instead, the idea is that your back-end prepares the HTML code that
should be rendered on the screen. And that could be an entire page or just a snippet, just a fragment. And HTMX then makes sure that that response HTML code is inserted in the right place in the DOM. So, in the website the user sees. And you control where exactly that response HTML code will be inserted. And how it will be inserted with special attributes, special HTMX attributes that
you can add to elements. So that you could use these HTMX attributes to make sure that when a form is submitted, a POST request is sent to a certain route, and the response HTML code that is sent back is then inserted in a specific place in the currently visible page. That's the idea with HTMX. And you don't need to write any JavaScript code for setting up the request, for sending the request, for
preparing the data, for using the response data and for updating the DOM. You don't need to do any of that. HTMX does it for you. That's the main idea. Now, of course, since HTMX essentially needs a back-end that sends back HTML snippets or documents instead of JSON data, you can really only use HTMX if you own the back-end, if you're building a
full-stack application in the end. Because only then can you make sure that it is such HTML data that's sent back instead of JSON data. So that is essentially a requirement, you could say. And that, of course, also means that if you're maybe building a back-end that's not just meant to be used by a web front-end, but also by a mobile app, for example, you might think twice whether
you really want to use HTMX or not, because you might need to send JSON data to the mobile app and HTML data to the web app if it uses HTMX. And maintaining these two different APIs or these different sets of API endpoints might not be something you want to do. In addition, if you're building a super complex web user interface with a lot of interactivity, if you're building something like Google Docs or anything like that,
you also might still want a library or framework like React or Angular because you have a lot of DOM updating to do and it's not all related to HTTP requests being sent back and forth. And in such a situation, HTMX also might not be perfect, though you could also definitely use it for applications like this. Also, because as I mentioned before, you're not limited to just using HTMX.
You can use it and combine it with vanilla JavaScript code or with some other JavaScript library. You can do that. It's not an either-or decision. But still, I'd say HTMX shines the most if you are building a full-stack web application where you do own the back-end, where you don't necessarily have other clients like a mobile app, and where you definitely have not
necessarily a trivial website, but also not a website that is hyper-interactive and that got a lot of things going on. And it turns out, at least in my experience, that quite a few websites are like that. They are not super complex. They don't need a super-interactive, complex web user interface. Instead, if you're building something like an online shop where you're essentially fetching products, fetching product
details, updating a cart, and so on, that's something HTMX can do really well. You don't necessarily have a UI that needs to be powered 100% by JavaScript or by JavaScript code you write, to be precise. Instead, HTMX might be a great choice in situations like that. And therefore, even if you don't plan on taking my course, which is fine, though I, of course, am happy if I can welcome
you there, but even if you don't do that, I would definitely recommend that you give HTMX a try because it really is an amazing library, in my opinion, because it can help you write less code, simpler code, and build websites quicker than you might be able to do with React or Next. Because I think as web developers, or as humans in general, I don't know, we sometimes tend to use the wrong tool or
maybe not the perfect tool for a given job. And I feel like HTMX can sometimes be the better tool for certain kinds of websites than React or Angular might be. Of course, it also comes down to personal preference, and that's why I say that you should give it a try. You don't have to use it, but at least you should be able to use it if you want to, and you should know about it. And therefore, definitely have a look at it
in the internet. As always, you will find lots of opinions on it, some pretty extreme opinions in both directions, and well, just ignore them. That's always the best thing to do in the internet. Don't read what people are writing about all these libraries and frameworks. Try to find the middle ground and just give it a try. It's really easy to get started with it, and with my course, I, of course, try my best to make it as easy as possible, whilst also
diving a bit deeper into HTMX and explaining a bit more about it and also showing you more advanced features. But you will see, using it is really simple in the end. In the course, we start at zero, and we then gradually dive deeper, but you can, of course, also take a look at the official docs, also in addition to the course, and who knows, maybe HTMX is also a great choice for your next project. I'm super interested in learning what
you think about it, so please share your opinion on HTMX. Let me know if you used it, if you like it, what you don't like about it, maybe, and well, maybe I also see you in the course. But even if I don't, HTMX, in my opinion, is pretty amazing, and you also might want to give it a try.
GPT 6 Astra was released. It's a good model, I have to say. Especially for 3D work it seems to be a real game changer. But due to all the hype, you may be disappointed...