finds.dev← search

// the find

gnat/surreal

★ 1,719 · JavaScript · MIT · updated May 2026

🗿 Mini jQuery alternative. Dependency-free animations. Locality of Behavior. Use one element or arrays transparently. Pairs with htmx. Vanilla querySelector() but better!

Surreal is a 320-line, dependency-free jQuery-style DOM helper that adds `me()` and `any()` as cleaner aliases for querySelector/querySelectorAll, plus chaining, event helpers, and async animation timelines. It's aimed at developers who want a little jQuery ergonomics without pulling in a framework — particularly those already using htmx. The 'Locality of Behavior' angle lets you write `me()` inside an inline `<script>` tag to grab the parent element without needing an ID.

The `me()` vs `any()` split is genuinely useful — it makes explicit whether you expect one element or many, which jQuery's `$()` never did cleanly. The async timeline pattern using `sleep()` gives you readable sequential animations without a separate animation library. The plugin system is simple and surgical: push a function onto `surreal.plugins`, and it gets wired into the chain automatically. At 320 lines with no build step, the whole thing is auditable in an afternoon.

Polluting globals via `globalsAdd()` is on by default, which means `me`, `any`, `sleep`, `halt`, and friends land on `window` — a naming collision waiting to happen in any project that's more than a few files. The `me()` parent-detection trick only works in synchronous inline scripts; the README itself warns it breaks inside `<script type='module'>`, which is most modern bundler output. Event removal with `off()` requires keeping a reference to the original function, same footgun as vanilla `removeEventListener`. With 1,700 stars and only 29 forks, there's almost no community-contributed extension or battle-testing signal.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →