Calmcode - htmx: introduction

Introducing HTMX

1 2 3 4 5 6 7

A website is typically split into two parts: the frontend part and the backend part. The front end represents what your users might see, and the backend has all sorts of logic to make sure that the front end looks the way it should.

Typically, the front end would send the request to the backend. The backend might then check the database to get the right values, and then after doing some business logic, the backend will return something to the front end such that the front end can update itself for the last few years.

The most typical way of going about this is to have the backend return JSON, and in turn, the front end would run some JavaScript to turn that into HTML that the user can see. This is all well and good, but it does mean that if you are a Python developer that you may feel like you are forced to learn JavaScript to build a web app. There is also a risk of putting too much JavaScript on your website, which can make it a bit slow. How about we do it differently? Instead of relying on JavaScript to turn this JSON into HTML, how about we just have the browser return HTML that it should place on the front end?

This is what HTMX makes super easy. And it results in a lot of very like-able patterns. The goal of this short course is kick the tires and show how you might build interactive web experience using just a bit of Python and HTML.