I'm surfing on the trend of HTMX

I'm tired of JS, not to mention TS and mostly I blame the whole JS ecosystem.

If I can come in time to tell one thing to my younger self I will tell him all in BTC back in 2012! Just kidding, I will tell him to choose Java or at least C# Asp.net. Don't choose anything that trendy when you are still a novice, j/k again, who knows what the future holds? And we can't time travel.

JS is still my main tech stack on the backend, along with Go, and C#. But on frontend, I don't have a choice but JS. While the backend can change easily, the frontend is different, I'm not a frontend guy so I don't have a passion for refactoring, or rewriting frontend code regardless of whatever the technology it was.

I am also tired of Webpack, frontend build pipeline, and dependencies chain break because the author adopted something new to their repo. I want to stay with the stable version, but then Dependabot says I have some security risks if I stay with some specific version. What should I do but not to stay up-to-date with my dependencies?

It is time to experiment. But if I do serverside rendering I will go back to the day of PHP and the template engine, back to the AJAX and JQuery if I want to make the page not reload on every click. Then I found HTMX and these things make sense

  • Why should only <a> and <form> be able to make HTTP requests?

  • Why should only click & submit events trigger them?

  • Why should only GET & POST methods be available?

  • Why should you only be able to replace the entire screen?

By removing these arbitrary constraints, htmx completes HTML as a hypertext

htmx is a library that allows you to access modern browser features directly from HTML, rather than using javascript.

With HTMX I don't have to use JS anymore, so it requires the server to work together to produce updated HTML (no page reload). The communication between the backend and frontend now is HTML, not JSON, so the server is in charge of frontend logic.

I like this idea, based on my experience, putting the business logic on frontend is a mess, the frontend guy tended to work with frontend only, they tried some magic with the backend JSON response to satisfy the business logic and left the mess here. We asked each other many times, where is the bug, frontend or backend. Hence we can easily trace it, but it is still time-consuming.

We should let the frontend guy do what he does best: frontend, styling, animation. The backend guy does the computation, and data formatting.

Enough talking, in the next part, I will start writing an htmx application.