Coder Social home page Coder Social logo

borrus-sudo / million Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aidenybai/million

1.0 2.0 0.0 4.73 MB

🦁 <1kb compiler-augmented virtual DOM. It's fast!

Home Page: https://million.js.org

License: MIT License

TypeScript 88.19% Shell 0.84% JavaScript 5.82% HTML 4.00% CSS 1.14%

million's Introduction

A lightweight (<1kB) compiler-augmented Virtual DOM. It's fast!

CI Code Size NPM Version Code Coverage

What is Million?

Current Virtual DOM implementations are inadequateβ€”Ranging from overcomplicated to abandoned, most are unusable without sacrificing raw performance and size.

Million aims to fix this, providing a library-agnostic Virtual DOM to serve as the core for Javascript libraries that focus on precompilation and static analysis.

β†’ Check out the Million website

Why Million?

  • 🦁 Built for libraries that compile
  • πŸ“¦ Lightweight bundle size (<1kb brotli+min)
  • ⚑ Fast runtime operations
  • πŸ› οΈ Composable using drivers, sensible by default

Installing Million

Inside your project directory, run the following command:

npm install million

Quick Start

Below is an extremely simple implementation of a Counter page using Million.

import { m, createElement, patch } from 'million';

const view = (seconds) => m('p', undefined, [`Time elapsed: ${seconds}`]);

const el = createElement(view(0));

let seconds = 0;

setInterval(() => {
  patch(el, view(seconds));
  seconds++;
}, 1000);

document.body.appendChild(el);

patch() function has a standard interface that is used in many Virtual DOM libraries. First argument is a DOM node that will be used as the live DOM reference, and the second one is a Virtual DOM to render.

createElement() function converts a "Virtual DOM" node into a real DOM node.

m() function will instantiate a "Virtual DOM" node for an element.

β†’ See live example

Resources & Contributing Back

Looking for the docs? Check the documentation out.

Have a question about Million? Post it on the GitHub Discussions and ask the community for help.

Find a bug? Head over to our issue tracker and we'll do our best to help. We love pull requests, too!

We expect all Million contributors to abide by the terms of our Code of Conduct.

β†’ Start contributing on GitHub (pnpm welcome)

Acknowledgments

Million takes heavy inspiration from snabbdom, ivi, mikado, and more. Feel free to check them out if you interested in an alternative library to use.

Why is it called "Million"? The name originated with the goal of being able to handle 1M+ ops/sec for benchmarks.

What is the logo? The logo stems from the suffix of Million, and is a graphic of the nose and mouth of a lion.

Sponsors

Vercel

Want your logo here? β†’ Sponsor Million

License

Million is MIT-licensed open-source software and research by Aiden Bai.

View count

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.