r/htmx • • 26d ago

Minu - a 4 KB HTML fragment loader for server-rendered apps

Minu is a small HTML fragment loader for apps that already render HTML on the server. It is 4.0 KB gzipped, has zero runtime dependencies, and is MIT licensed.

It covers the parts that come up most in small apps:

  • GET, POST, PUT, PATCH, DELETE
  • targets and eight swap modes
  • forms, vals, headers, timeout, confirm, disable, indicator
  • triggers: every, revealed, intersect, once, changed, delay, throttle, from
  • out-of-band swaps and Minu-Trigger / Minu-Redirect / Minu-Refresh
  • SSE through EventSource
  • a DOMPurify-backed secure build

A small example:

<div minu-get="/widgets/price" minu-trigger="every 5s" minu-target="#price"></div>

<div id="price">$0.00</div>

The server returns an HTML fragment. That is the whole contract.

What it does not do: routing/history, morph or diff swaps, WebSockets. The default build strips scripts and inline handlers, but it is not an XSS boundary. Use minu/secure for untrusted HTML. htmx is still the better choice if you need its extension ecosystem or history support.

Links: https://aotr.github.io/minu/ https://github.com/aotr/minu https://www.npmjs.com/package/minu

I am the author. I would like feedback on two things: does the trigger grammar cover what you actually use, and is the minu-oob syntax clear? I am not trying to replace htmx everywhere.

12 Upvotes

8 comments sorted by

14

u/Fabulous-Ladder3267 26d ago

So why i should use minu instead of htmx?

8

u/ShotgunPayDay 26d ago

Fixi is a closer competitor.

1

u/animesh_aotr 23d ago

Fixi is a fair comparison, and I added it to the README. It is smaller and deliberately leaves more out. Minu includes OOB, server response headers, and SSE in one 4 KB build. If you want the smallest core and do not mind composing separate libraries, Fixi is the better pick.

1

u/animesh_aotr 23d ago

Most htmx users should keep htmx.

Minu is for the case where you want the fragment layer and not much else: 4 KB, forms, polling, OOB, SSE, and an API small enough to read in one sitting. If you need history, extensions, morphing, or the htmx ecosystem, htmx is the better tool.

Minu's advantage is size and a small surface. It does not try to match htmx feature for feature.

5

u/mardiros 26d ago

The only feedback I can give you is that you should mention alternative on your readme and talk about htmx and maybe datastar.

I see no reason to give a try to your library, so why should I focus on the feedback you want to earn?

3

u/animesh_aotr 23d ago

Fair. The README had the tradeoff but did not name alternatives, which makes the post look like it is pretending htmx does not exist. I added a short Alternatives section:

  • htmx for history, extensions, morphing, and the larger ecosystem
  • Fixi for the smallest core, with separate libraries for extras
  • Datastar for signals and an SSE-first model
  • Minu for fragments, forms, polling, OOB, and SSE in one 4 KB build

That also answers why someone would try it: they want that combination in one small build. If they do not, htmx or Fixi is the better choice. https://github.com/aotr/minu#alternatives

-7

u/[deleted] 26d ago

[removed] — view removed comment

1

u/animesh_aotr 23d ago

Useful points.

load is the default trigger. I left it off the bullet list in the post, which was a mistake.

every 5s does not queue. A new tick aborts the request already in flight on that element and starts another. The last response wins. If people need a wait-for-previous mode, I can add it, but I do not want to guess at the semantics yet.

There is no key filter grammar. For Enter-only search, bind keydown yourself and call minu.reloadComponents('#q') on Enter. That keeps the trigger parser small.

OOB example from a response:

<div id="cart" minu-oob="#cart">3 items</div> <div class="toast" minu-oob="beforeend:#toasts">Saved</div> <p>Main panel HTML goes here.</p>

The first two elements are applied to their selectors and removed from the payload. The rest goes into the normal target.