Debian Codegraph @

www/src/content/essays/alternatives.md

raw symbols SCIP
1 ---
2 title: "Alternatives to htmx"
3 description: "In this article, Carson Gross compares several alternative libraries and frameworks to htmx that embrace a hypermedia-oriented approach to web development. Carson explores established solutions like Unpoly and Hotwire Turbo, as well as emerging projects like Triptych and htmz, providing developers with a comprehensive overview of hypermedia-driven application development options beyond htmx."
4 created: 2025-01-12
5 modified: 2025-01-12
6 authors: [ "Carson Gross" ]
7 tags: ["counterpoints"]
8 ---
9
10 [htmx](/) is only one of many different libraries & frameworks that take the
11 [hypermedia oriented](/essays/hypermedia-driven-applications) approach to building web applications. I have
12 said before that I think the [ideas of htmx](/essays) / [hypermedia](https://hypermedia.systems) are more important than
13 htmx as an implementation.
14
15 Here are some of my favorite other takes on these ideas that I think are worth your consideration:
16
17 ## Unpoly
18
19 [Unpoly](https://unpoly.com/) is a wonderful, mature front end framework that has been used heavily (especially in the
20 ruby community) for over a decade now. It offers
21 best-in-class [progressive enhancement](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement)
22 and has many useful concepts such as [layers](https://unpoly.com/up.layer) and sophisticated
23 [form validation](https://unpoly.com/validation).
24
25 I interviewed the author, Henning Koch, [here](/essays/interviews/henning_koch)
26
27 You can see a demo application using Unpoly [here](https://demo.unpoly.com/).
28
29 ## Triptych
30
31 [Triptych](https://github.com/alexpetros/triptych) is a set of [three proposals](https://alexanderpetros.com/triptych/)
32 to bring more generalized hypermedia controls directly into the HTML specification:
33
34 * Allow more [HTTP Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) to be used directly from HTML
35 * Allow buttons to act as stand-alone hypermedia controls
36 * Allow hypermedia controls to target any element on the page for replacement
37
38 It is [in the process](https://github.com/whatwg/html/issues/3577#issuecomment-2294931398) of being introduced to the
39 [WHATWG](https://whatwg.org/) for inclusion in the HTML specification.
40
41 The project includes a [polyfill](https://github.com/alexpetros/triptych/blob/main/triptych.js) that can be used today
42 to implement applications using the proposal today.
43
44 ## fixi.js
45
46 [fixi.js](https://github.com/bigskysoftware/fixi) is a minimalist implementation of
47 [generalized hypermedia controls](https://dl.acm.org/doi/fullHtml/10.1145/3648188.3675127) by the htmx team, focusing
48 on being as small as possible and [omitting](https://github.com/bigskysoftware/fixi#minimalism) many of the features
49 found in htmx.
50
51 It is intended to be as small as possible (~3.5k unminified & uncompressed, ~1.3k compressed) while still being readable
52 and debuggable, so it can be included in a project directly without requiring any transformations.
53
54 ## Datastar
55
56 [Datastar](https://data-star.dev/) started life as a proposed rewrite of htmx in typescript and with modern
57 tooling. It eventually became its own project and takes
58 an [SSE-oriented](https://data-star.dev/guide/getting_started#backend-setup)
59 approach to hypermedia.
60
61 Datastar combines functionality found in both htmx and [Alpine.js](https://alpinejs.dev/) into
62 a single, tidy package that is smaller than htmx.
63
64 You can see many examples of Datastar in action [here](https://data-star.dev/examples).
65
66 ## Alpine-ajax
67
68 Speaking of Alpine (which is a common library to use in conjunction with htmx) you should look at
69 [Alpine AJAX](https://alpine-ajax.js.org/), an Alpine plugin which integrates htmx-like concepts directly into Alpine.
70
71 If you are already an Alpine enthusiast, Alpine AJAX allows you to stay in that world.
72
73 You can see many examples of Alpine AJAX in action [here](https://alpine-ajax.js.org/examples/).
74
75 ## Hotwire Turbo
76
77 [Turbo](https://turbo.hotwired.dev/) is a component of the [Hotwire](https://hotwired.dev/) set of web development
78 technologies by [37Signals](https://37signals.com/), of [Ruby on Rails](https://rubyonrails.org/) fame. It is a polished
79 front end framework that is used heavily in the rails community, but can be used with other backend technologies as
80 well.
81
82 Some people who have had a bad experience with htmx [have enjoyed turbo](https://news.ycombinator.com/item?id=42615663).
83
84 ## htmz
85
86 [htmz](https://leanrada.com/htmz/) is a brilliant, tiny library that takes advantage of the fact that anchors and forms
87 already have a [`target`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target) attribute that can target
88 an `iframe`.
89
90 This, in combination with the `location hash`, is used to
91 allow [generalized transclusion](https://dl.acm.org/doi/fullHtml/10.1145/3648188.3675127#sec-7).
92
93 This is the *entire* source of the library (I'm not joking):
94
95 ```html
96
97 <iframe hidden name=htmz
98 onload="setTimeout(()=>document.querySelector(contentWindow.location.hash||null)?.replaceWith(...contentDocument.body.childNodes))"></iframe>
99 ```
100
101 Amazing!
102
103 ## TwinSpark
104
105 [TwinSpark](https://twinspark.js.org/) is a library created by [Alexander Solovyov](https://solovyov.net/) that is
106 similar to htmx, and includes features such as [morphing](https://twinspark.js.org/api/ts-swap/#morph).
107
108 It is being [used in production](https://twinspark.js.org#who-is-using-this) on sites with 100k+ daily users.
109
110 ## jQuery
111
112 Finally, good ol' [jQuery](https://jquery.com/) has the the [
113 `load()`](https://api.jquery.com/load/#load-url-data-complete)
114 function that will load a given url into an element. This method was part of the inspiration for
115 [intercooler.js](https://intercoolerjs.org), the precursor to htmx.
116
117 It is very simple to use:
118
119 ```javascript
120 $("#result").load("ajax/test.html");
121 ```
122
123 and might be enough for your needs if you are already using jQuery.
124
125 ## Conclusion
126
127 I hope that if htmx isn't right for your application, one of these other libraries might be useful in allowing you to
128 utilize the hypermedia model. There is a lot of exciting stuff happening in the hypermedia world right now, and these
129 libraries each contribute to that.
130
131 Finally, if you have a moment, please give them (especially the newer ones) a star on Github: as an open source
132 developer I know that Github stars are one of the best psychological boosts that help keep me going.
133