DEV Community

Cover image for πŸ”₯Best alternative to HTMX

πŸ”₯Best alternative to HTMX

Anthony Max on February 16, 2025

Hello everyone! In this article we will consider such a javascript module as HMPL and how it can replace HTMX in a project. Also consider their dif...
Collapse
 
brense profile image
Rense Bakker β€’

Wait, we already need an alternative to HTMX? I thought HTMX was going to replace all the frontend frameworks?

Collapse
 
dariomannu profile image
Dario Mannu β€’ β€’ Edited

HTMX was going to replace...

you may have been the victim of a scam πŸ€ͺ

Collapse
 
anthonymax profile image
Anthony Max β€’

I understand why XMLHTTPRequest in 2025 is due to overrideMimeType, but it would seem that behind such a convenience lies the fact that the route can send you any type, and it will be overwritten instead of an error. Well, and we shouldn't forget about backward compatibility and other things either.

Collapse
 
anthonymax profile image
Anthony Max β€’

I respect htmx, but with all the desire to say that it will replace, it would not be entirely correct. I just see what is being replaced (XMLHTTPRequest requests without almost any customization), especially when it comes to working with a server in 2025. I understand why this is so, because that's the whole point. In a certain simplicity and functionality, but, in my opinion, there are also disadvantages to this approach.

Collapse
 
moopet profile image
Ben Sinclair β€’
Collapse
 
volodymyrptk profile image
VolodymyrPTK β€’

is alternative to alternative to alternative...

Collapse
 
pengeszikra profile image
Peter Vivo β€’

Is possible to work with a component in HMPL, and how?

Collapse
 
anthonymax profile image
Anthony Max β€’

I don't quite understand in what sense the word component is used here. If it is in the understanding of React a type of function that returns jsx markup (everything is conditional, because it returns a regular object), then HMPL is not connected with React and other frameworks and libraries. But, this does not mean that it cannot be used in conjunction with them. In React you can easily work through ref and there will be no problems.

Collapse
 
pengeszikra profile image
Peter Vivo β€’

In bare simple HTML if I need to create a component ( repeated url element ), I wrote as template tag and a I used that clone for a greater speed.

Thread Thread
 
anthonymax profile image
Anthony Max β€’

If we take regular HTML, then HMPL with template is definitely good)

Collapse
 
lukasborawski profile image
Lukas Borawski β€’

Wait, these are all strings?

Collapse
 
anthonymax profile image
Anthony Max β€’

HTMX is all HTML.Vue and HMPL - js code with template strings. It was possible to show HMPL via HTML when a request object is simply passed, but I wanted to demonstrate the customization possibilities

Collapse
 
gamerdev13 profile image
Martin Green β€’

Good article! I would also like to say something about PHP and compare.

Collapse
 
anthonymax profile image
Anthony Max β€’

Thank you! What does this have to do with anything now?)

Collapse
 
anthonymax profile image
Anthony Max β€’

I would also add online examples on codepen, but I think the code there is small, so it seems ok.

Collapse
 
pengeszikra profile image
Peter Vivo β€’ β€’ Edited

Thx for this article. When I need to choose between HTMX and HMPL according this article, my favorite is HTMX, because HTMX can use much more simpler. I just need to copy this HTML code to FE part to work it, and do not need further state or DOM handling, because HTMX solve that "problem".

Imho: a real raw level to make any webpage (FE perspective):

  • level 1: just write a HTML page, without compile.
  • level 2: HTML with a CSS / JS, without compile.
  • level 3: HTML with a CDN javascript, without compile --> HTMX
  • level 4: SSR level 1-3 on server side. Without compile or build any JS on server side. --> PHP
  • level 5: FE maked by framework --> React, Vue, SolidJS ...
  • level 6+: FE created SSR --> HMPL
Collapse
 
anthonymax profile image
Anthony Max β€’

Well, according to the description of your task, maybe HTMX will be advantageous because it is easier to set up - I do not argue. But, if you still want to send custom requests and more fully control the process, then, as described in the article, I can offer you HMPL as an alternative. Trivially, if you just need to quickly transfer part of the code to HTML, then HTMX, yes, in principle, is the choice that is needed, but if we are talking about more or less complete work with js with process control, then, again, you can consider HMPL.

Collapse
 
pengeszikra profile image
Peter Vivo β€’

Don't make mistake, I never used a HTMX. Even I don't think that is a best way, because just a hide a lot of things, and you right a certain point you will be need to use external JS function for it.

My perspective of point is a multi page simple HTML with a minimal JS. Maybe a better than relally obviously page ( like a game where a custom realtime interaction is take a place ) I use some JSX based setup ( even without FW ).

Collapse
 
anthonymax profile image
Anthony Max β€’

I'm not discouraging anyone from using something. I'm just offering an alternative. HTMX is simpler from the start - yes. That's its feature. But I think that simplifying everything is not worth it either. For me, the golden mean is better, which is implemented in HMPL, when you don't write very big code, and have the ability to control the process of sending a request and work in js fully.

Collapse
 
documendous profile image
Documendous β€’ β€’ Edited

Thanks very much for the write up. You did a good job! Since I use it everyday at work, I would opine that HTMX is much more natural and much easier to read. It also has way more features than other alternatives.

Collapse
 
anthonymax profile image
Anthony Max β€’

Yes, more features. But you can't send custom requests to the server, and you also depend on the DOM. I don't argue that HTMX is easy to read, but this syntax has its downsides.

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ β€’

Take a look at HTMZ - it only weighs 166 bytes (yes, bytes) and is super flexible.