TIL HTMX is way faster than writing AJAX logic directly inside a Django template

benji011

Benji 🍙

Posted on May 16, 2023

TIL HTMX is way faster than writing AJAX logic directly inside a Django template

e.g. In my Django template I might have:

{% load ajax %}

<button id="my-button">Click me</button>

<script>
$(document).on("click", "#my-button", function() {
  $.ajax({
    url: "/my-view",
    type: "GET",
    success: function(data) {
      // Do stuff
    }
  });
});
</script>
Enter fullscreen mode Exit fullscreen mode

but with HTMX you can just do this:

<button id="my-button" hx-post="/my-view"></button>

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
benji011
Benji 🍙

Posted on May 16, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related