npm: npm install sinuous --save
cdn: https://unpkg.com/sinuous
module: https://unpkg.com/sinuous?module
Sinuous provides the clarity of declarative views and the performance of direct DOM manipulation.
It was built with these ideas in mind.
- Small: use in other mini libraries like custom elements.
- Simple: plain Javascript feel; template literals, standard HTML.
- Performance: top ranked of 80+ UI libs
Size | Name | Description |
---|---|---|
sinuous/map |
Fast list renderer | |
sinuous/template |
Pre-rendered Template | |
sinuous/observable |
Tiny observable |
Counter Example (1.4kB gzip) (Codesandbox)
import { o, html } from 'sinuous';
const counter = o(0);
const view = () => {
return html`
<div>Counter ${counter}</div>
`;
};
document.body.append(view());
setInterval(() => counter(counter() + 1), 1000);
- Counter Simple Counter
- SVG Clock Analog SVG Clock
- TodoMVC Classic TodoMVC example
- JS Framework Benchmark Most Popular UI library bench
The motivation for Sinuous was to create a very lightweight UI library to use in our video player at Vimeo. The view layer in the player is rendered by innerHTML and native DOM operations which is probably the best in terms of performance and bundle size. However the need for a more declarative way of doing things is starting to creep up. Even if it's just for ergonomics.
The basic requirements are a small library size, small application size growth, fast TTI, not crucial but good render performance (creating & updating of DOM nodes).
More importantly, the developer experience. Working close to the metal with as few specialized syntaxes as possible is a key goal for Sinuous. The html``
tag returns a native Node
instance and the components are nothing more than simple function calls in the view.
Another essential aspect is modularity, Sinuous is structured in a way that you only pay for what you use.
Sinuous started as a little experiment to get similar behavior as Surplus but with template literals instead of JSX.
HTM compiles to an h
tag. Adapted code from Ryan Solid's dom expressions + a Reactive library provides the reactivity.
Sinuous returns a hyperscript function which is armed to handle the callback functions from the reactive library and updates the DOM accordingly.
Sinuous supports modern browsers and IE9+ but keep in mind that IE9 and IE10 do require a polyfill for the Map
and Set
collection type.
Sinuous can work with different observable libraries. See the wiki for more info.
Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs