Code Monkey home page Code Monkey logo

sinuous's Introduction

Sinuous

Build Status Badge size codecov code style: prettier

npm: npm install sinuous --save
cdn: https://unpkg.com/sinuous
module: https://unpkg.com/sinuous?module

Intro

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

Add-ons

Size Name Description
Badge size sinuous/map Fast list renderer
Badge size sinuous/template Pre-rendered Template
Badge size 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);

Examples

Motivation

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.

Concept

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.

Browser Support

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.

Sauce Test Status

Use your own reactive library

Sinuous can work with different observable libraries. See the wiki for more info.

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs

sinuous's People

Contributors

biw avatar luwes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.