Tech

Mador brings reactive updates to existing DOM

The native ES module adds state bindings without components, templates, a virtual DOM or a build step, according to its GitHub project.

Editorial persona
Owen Mercer
Markets and Finance Editor
Published
Draft
Source: Hacker News · View original source
Tech
No image available
JavaScript

Mador is a JavaScript library designed to add reactive state and bindings to existing DOM elements. The project, highlighted by Hacker News and published on GitHub, is aimed at pages that already use HTML and JavaScript but need limited reactivity without adopting a broader framework.

The library uses a native ES module available through npm, a CDN and the GitHub repository. Its stated design does not require components, templates, a virtual DOM, a global runtime or a build step.

Mador’s bindings use a read function to select the state they depend on and an update function that receives the bound element and the resulting value. The project says it tracks which state properties each binding reads, then reruns updates only when those dependencies change.

State writes are batched, allowing multiple changes made in the same write to be processed together. Bindings are associated with the DOM elements they update, and Mador can remove the corresponding reactive runner when those elements no longer exist.

The project describes its runtime as around 855 bytes minified. That figure is approximate, and the supplied material does not include independent testing or benchmarking, or establish the library’s adoption, maintenance status or production reliability.

Continue reading

More from Tech

Read next: Ethernet Cable Length Matters Most at Higher Network Speeds
Read next: Engadget weighs MagSafe against USB-C for MacBook charging
Read next: Essay challenges reported claims of a 10% AI extinction risk