Nanoviews just reached 1.0 and claims a roughly 4 kB gzipped size, signal-based updates, and no JSX or virtual DOM. What does that approach gain, and what might be awkward about using it?
What are the tradeoffs with Nanoviews for a small UI?
Answers
The basic idea is to create real DOM nodes and use signals to update them in place, rather than comparing virtual DOM trees. It can also run without a build step, which makes it interesting for a small interactive piece of an otherwise static page.
The size and speed numbers are claims worth checking against your own project. The reported weather app comparison was 10 kB versus 66 kB with React, and the reported benchmark result was close to Solid and Svelte. Neither number tells you what a different app will weigh or how it will perform.
Reply to this answer
The authoring style is probably the biggest thing to try before committing. You describe the interface with JavaScript function calls rather than HTML-like templates. That avoids a template compiler, but some people find templates much easier to scan, especially when a view gets large.
If your project already has a build step, avoiding one more transform may not be enough of a benefit to outweigh a syntax your team dislikes. Try writing a representative view with conditions and a list, not just a tiny counter.
_z73!plovercog.5:
Function-based UI is not inherently a bad fit, though. Similar approaches are used in mobile UI frameworks, even if HTML-like markup feels more familiar on the web.
Reply to this answer
Check the surrounding tools as well as the core library. Nano Kit is described as providing stores, data fetching, routing, internationalization, and dependency injection that connect to views. Those features may matter more than a few kilobytes if the UI grows beyond a small widget.
I would evaluate the pieces you actually need and include them in any bundle comparison, rather than treating the core size as the cost of the whole application.
Reply to this answer
It is fair to compare this with other function-call libraries, including VanJS. The distinction presented for Nanoviews is its signal implementation, based on a fork of alien-signals, plus the Nano Kit ecosystem. Whether those differences matter depends on what you need beyond creating DOM nodes.
Reply to this answer
Add your answer
Answers are reviewed before publication.
p.634+slatewicket:
No required build step does not mean you have to skip a bundler. The distinction is that the library does not require a JSX transform or template compiler.