Simple DOM ops
Select, read and update elements through one consistent call.
A tiny DOM manipulation library. Simple DOM operations, events and templating helpers — exposed through one minimal, chainable API written on the global µ.
Select, read and update elements through one consistent call.
Attach and reason about interaction without ceremony.
Compose markup with small, readable helpers.
One entry point. A surface you can hold in your head.
No runtime dependencies. The core is a single tiny file.
Drop in a <script> tag or import from a CDN.
Zero dependencies. Mode.js ships with no runtime dependencies — the whole core is a single tiny file.
terminal
npm install @microdom/mode
Each entry point ships in three formats — pick the one that matches how you load it.
| File | Format | Load with |
|---|---|---|
dist/mode.js | ESM | import (bundlers, <script type="module">) |
dist/mode.esm.min.js | ESM, minified | import for the smallest module build |
dist/mode.min.js | IIFE | classic <script> — exposes the global µ |
An IIFE build has no exports, so it can't be imported — use an ESM build for import, and the IIFE for a plain <script>.
Resolves to the ESM build:
app.js
import µ from "@microdom/mode"
// or: import { µ } from "@microdom/mode"
Global µ, no build step:
index.html
<script src="https://cdn.jsdelivr.net/gh/microdom/mode.js@v1.1.0/dist/mode.min.js"></script>
<script>
µ("body", { /* ... */ })
</script>
index.html
<script type="module">
import µ from "https://cdn.jsdelivr.net/gh/microdom/mode.js@v1.1.0/dist/mode.js"
µ("body", { /* ... */ })
</script>
Optional extension
Animations live in a separate, optional extension so the core stays tiny. Load it and Mode gains slide / fade / animate / show / hide commands plus the offset / pos getters — all chained through the same µ(...) call.
movedom.js
µ("#panel", { slideUp: { t: 300 } })
µ("#panel", { fadeIn: { t: 200, fn: () => console.log("done") } })
µ("#box", { animate: { props: { width: 400 }, t: 500, easing: "easeOut" } })
µ("#box", { stop: {} }) // cancel running animation
const off = µ("#box", { offset: null }) // → { top, left }
If an interaction cannot be expressed simply, the abstraction is probably wrong.