{"id":13457628,"url":"https://github.com/aidenybai/million","last_synced_at":"2025-05-13T20:05:48.546Z","repository":{"id":37016460,"uuid":"372046384","full_name":"aidenybai/million","owner":"aidenybai","description":"Optimize React performance and make your React 70% faster in minutes, not months. ","archived":false,"fork":false,"pushed_at":"2024-07-15T00:32:00.000Z","size":89162,"stargazers_count":17136,"open_issues_count":118,"forks_count":584,"subscribers_count":64,"default_branch":"main","last_synced_at":"2025-05-06T19:52:02.402Z","etag":null,"topics":["best-practices","blockdom","compiler","hacktoberfest","memo","million","millionjs","optimization","optimize","performance","preact","react","react-hooks","react-optimize","renderer","rendering","virtual-dom"],"latest_commit_sha":null,"homepage":"https://million.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aidenybai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["aidenybai"]}},"created_at":"2021-05-29T18:38:23.000Z","updated_at":"2025-05-06T18:12:02.000Z","dependencies_parsed_at":"2024-11-12T07:03:25.547Z","dependency_job_id":"38a3ba55-1cbe-44a1-a576-cbcd10659c6a","html_url":"https://github.com/aidenybai/million","commit_stats":{"total_commits":2176,"total_committers":136,"mean_commits":16.0,"dds":"0.25735294117647056","last_synced_commit":"cca9ae2f59c2575301a4871ccd1c9d4c4f6022f4"},"previous_names":[],"tags_count":241,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenybai%2Fmillion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenybai%2Fmillion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenybai%2Fmillion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenybai%2Fmillion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aidenybai","download_url":"https://codeload.github.com/aidenybai/million/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020478,"owners_count":22000750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["best-practices","blockdom","compiler","hacktoberfest","memo","million","millionjs","optimization","optimize","performance","preact","react","react-hooks","react-optimize","renderer","rendering","virtual-dom"],"created_at":"2024-07-31T09:00:32.053Z","updated_at":"2025-05-13T20:05:48.522Z","avatar_url":"https://github.com/aidenybai.png","language":"TypeScript","readme":"\u003e Want to **automatically find and fix performance issues**? Check out [Million Lint](https://million.dev/).\n\n\u003ca href=\"https://million.dev\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/aidenybai/million/main/.github/assets/banner.png\" alt=\"Million.js Banner\" /\u003e\n\u003c/a\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://img.shields.io/github/actions/workflow/status/aidenybai/million/ci.yml?branch=main\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/aidenybai/million/ci.yml?branch=main\u0026style=flat\u0026colorA=000000\u0026colorB=000000\" alt=\"CI\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/million\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/million?style=flat\u0026colorA=000000\u0026colorB=000000\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/million\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/million.svg?style=flat\u0026colorA=000000\u0026colorB=000000\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://discord.gg/X9yFbcV2rF\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/discord/938129049539186758?style=flat\u0026colorA=000000\u0026colorB=000000\u0026label=discord\u0026logo=discord\u0026logoColor=ffffff\" /\u003e\u003c/a\u003e\n\n\u003ctable\u003e\n    \u003ctbody\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e\n          \u003ca href=\"https://million.dev/docs/introduction\"\u003e📚 Read the docs\u003c/a\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n          \u003ca href=\"https://www.youtube.com/watch?v=VkezQMb1DHw\"\u003e🎦 Watch video\u003c/a\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n          \u003ca href=\"https://million.dev/chat\"\u003e💬 Join our Discord\u003c/a\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n          \u003ca href=\"https://twitter.com/milliondotjs\"\u003e🌐 Follow on Twitter\u003c/a\u003e\n        \u003c/td\u003e\n      \u003c/tr\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/div\u003e\n\n## What is Million.js?\n\nMillion.js is an extremely fast and lightweight optimizing compiler that make [components](https://react.dev) up to [_**70% faster**_](https://krausest.github.io/js-framework-benchmark/current.html).\n\n\u003e Oh man... Another [`/virtual dom|javascript/gi`](https://regexr.com/6mr5f) framework? I'm fine with [React](https://reactjs.org) already, why do I need this?\n\nMillion.js works with React and makes reconciliation faster. By using a fine-tuned, optimized virtual DOM, Million.js reduces the overhead of diffing ([_try it out here_](https://demo.million.dev))\n\n**TL;DR:** Imagine [React](https://react.dev) components running at the speed of raw JavaScript.\n\n### [**👉 Setup Million.js in seconds! →**](https://million.dev/)\n\n## Installation\n\nThe Million.js CLI will automatically install the package and configure your project for you.\n\n```bash\nnpx million@latest\n```\n\nOnce your down, just run your project and information should show up in your command line!\n\n\u003e Having issues installing? [**→ View the installation guide**](https://million.dev/docs/install)\n\n## Why Million.js?\n\nTo understand why to use Million.js, we need to understand how React updates interfaces. When an application's state or props change, React undergoes an update in two parts: rendering and reconciliation.\n\nTo show this, let's say this is our `App`:\n\n```jsx\nfunction App() {\n  const [count, setCount] = useState(0);\n  const increment = () =\u003e setCount(count + 1);\n  return (\n    \u003cdiv\u003e\n      \u003cp\u003eCount: {count}\u003c/p\u003e\n      \u003cbutton onClick={increment}\u003eIncrement\u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\nIn this `App`, when I click on the button, the `count` state will update and the `\u003cp\u003e` tag will update to reflect the new value. Let's break this down.\n\n### Rendering\n\nThe first step is rendering. Rendering is the process of generating a snapshot of the current component. You can imagine it as simply \"calling\" the `App` function and storing the output in a variable. This is what the `App` snapshot would look like:\n\n```jsx\nconst snapshot = App();\n\n// snapshot =\n\u003cdiv\u003e\n  \u003cp\u003eCount: 1\u003c/p\u003e\n  \u003cbutton onClick={increment}\u003eIncrement\u003c/button\u003e\n\u003c/div\u003e;\n```\n\n### Reconciliation\n\nIn order to update the interface to reflect the new state, React needs to compare the previous snapshot to the new snapshot (_called \"diffing\"_). React's reconciler will go to each element in the previous snapshot and compare it to the new snapshot. If the element is the same, it will skip it. If the element is different, it will update it.\n\n- The `\u003cdiv\u003e` tag is the same, so it doesn't need to be updated. ✅\n  - The `\u003cp\u003e` tag is the same, so it doesn't needs to be updated. ✅\n    - The text inside the `\u003cp\u003e` tag is different, so it needs to be updated. ⚠ ️\n  - The `\u003cbutton\u003e` tag is the same, so it doesn't need to be updated. ✅\n    - The `onClick` prop is the same, so it doesn't need to be updated. ✅\n    - The text inside the `\u003cbutton\u003e` tag is the same, so it doesn't need to be updated. ✅\n\n_(total: 6 diff checks)_\n\n```diff\n\u003cdiv\u003e\n-  \u003cp\u003eCount: 0\u003c/p\u003e\n+  \u003cp\u003eCount: 1\u003c/p\u003e\n  \u003cbutton onClick={increment}\u003eIncrement\u003c/button\u003e\n\u003c/div\u003e\n```\n\nFrom here, we can see that the `\u003cp\u003e` tag needs to be updated. React will then update the `\u003cp\u003e` DOM node to reflect the new value.\n\n```jsx\n\u003cp\u003e.innerHTML = `Count: ${count}`;\n```\n\n### How Million.js makes this faster\n\nReact is slow.\n\nThe issue with React's reconciliation it becomes **exponentially slower** the more JSX elements you have. With this simple `App`, it only needs to diff a few elements. In a real world React app, you can easily have hundreds of elements, slowing down interface updates.\n\nMillion.js solves this by **skipping the diffing step entirely** and directly updating the DOM node.\n\nHere is a conceptual example of how Million.js reconciler works:\n\n```jsx\nfunction App() {\n  const [count, setCount] = useState(0);\n  const increment = () =\u003e setCount(count + 1);\n\n  // generated by compiler\n  if (count !== prevCount) {\n    \u003cp\u003e.innerHTML = `Count: ${count}`;\n  }\n\n  \u003cbutton\u003e.onclick = increment;\n\n  // ...\n}\n```\n\nNotice how when the `count` is updated, Million.js will directly update the DOM node. Million.js turns React reconciliation from `O(n)` (linear time) to `O(1)` (constant time).\n\n\u003e How fast is it? [**→ View the benchmarks**](https://krausest.github.io/js-framework-benchmark/current.html)\n\n## Resources \u0026 Contributing Back\n\nLooking for the docs? Check the [documentation](https://million.dev) or the [Contributing Guide](https://github.com/aidenybai/million/blob/main/.github/CONTRIBUTING.md) out. We also recommend reading [_Virtual DOM: Back in Block_](https://million.dev/blog/virtual-dom) to learn more about Million.js's internals.\n\nWant to talk to the community? Hop in our [Discord](https://discord.gg/X9yFbcV2rF) and share your ideas and what you've build with Million.js.\n\nFind a bug? Head over to our [issue tracker](https://github.com/aidenybai/million/issues) and we'll do our best to help. We love pull requests, too!\n\nWe expect all Million.js contributors to abide by the terms of our [Code of Conduct](https://github.com/aidenybai/million/blob/main/.github/CODE_OF_CONDUCT.md).\n\n[**→ Start contributing on GitHub**](https://github.com/aidenybai/million/blob/main/.github/CONTRIBUTING.md)\n\n![Alt](https://repobeats.axiom.co/api/embed/74a4b271e2a24c2cb08c897cfc1dfe155e0e1c1e.svg 'Repobeats analytics image')\n\n## Codebase\n\nThis repo is a \"mono-repo\" with modules. Million.js ships as one NPM package, but has first class modules for more complex, but important extensions. Each module has its own folder in the `/packages` directory.\n\nYou can also track our progress through our [Roadmap](https://github.com/users/aidenybai/projects/5/views/1?layout=roadmap).\n\n| Module                                                                                                                                                            | Description                                         |\n| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |\n| [`million`](https://github.com/aidenybai/million/tree/main/packages/million)                                                                                      | The main Virtual DOM with all of Million.js's core. |\n| [`react`](https://github.com/aidenybai/million/tree/main/packages/react) / [`react-server`](https://github.com/aidenybai/million/tree/main/packages/react-server) | React compatibility for Million.js.                 |\n| [`compiler`](https://github.com/aidenybai/million/tree/main/packages/compiler)                                                                                    | The compiler for Million.js in React.               |\n| [`jsx-runtime`](https://github.com/aidenybai/million/tree/main/packages/jsx-runtime)                                                                              | A simple JSX runtime for Million.js core.           |\n| [`types`](https://github.com/aidenybai/million/tree/main/packages/types)                                                                                          | Shared types between packages                       |\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sponsors/aidenybai\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/aidenybai/aidenybai/master/sponsors.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://vercel.com?utm_source=millionjs\u0026utm_campaign=oss\"\u003e\u003cimg height=\"30\" src=\"https://raw.githubusercontent.com/abumalick/powered-by-vercel/master/powered-by-vercel.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Acknowledgments\n\nMillion.js takes heavy inspiration from the following projects:\n\n- [`blockdom`](https://github.com/ged-odoo/blockdom) ([Géry Debongnie](https://github.com/ged-odoo))\n  Thank you to Géry pioneering the concept of \"blocks\" in the virtual DOM. Many parts of the Million.js codebase either directly or indirectly derive from his work.\n- [`voby`](https://github.com/vobyjs/voby) ([Fabio Spampinato](https://github.com/fabiospampinato))\n  The Million.js \"template\" concept is derived from Voby's `template()` API.\n- [Hack the Wave](https://hackthewave.com) ([Melinda Chang](https://github.com/melindachang)) for their homepage.\n- [`react`](https://react.dev) and [`turbo`](https://turbo.build) for their documentation. Many parts of the current Million.js documentation are grokked and modified from theirs.\n- [`ivi`](https://github.com/localvoid/ivi), [Preact](https://github.com/preactjs/preact), [and more](https://krausest.github.io/js-framework-benchmark/2021/table_chrome_96.0.4664.45.html)\n\n## License\n\nMillion.js is [MIT-licensed](LICENSE) open-source software by [Aiden Bai](https://aiden.mov) and [contributors](https://github.com/aidenybai/million/graphs/contributors):\n\n\u003ca href=\"https://github.com/aidenybai/million/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=aidenybai/million\" /\u003e\n\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/aidenybai"],"categories":["七、开发工具（提升开发效率）","TypeScript","MVC Frameworks and Libraries","**Awesome React** [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)","前端开发框架及项目","目录","Uncategorized","best-practices","node.js/javascript"],"sub_categories":["3.  Immutable 工具（辅助状态管理）","Runner","React","其他_文本生成、文本对话","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidenybai%2Fmillion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidenybai%2Fmillion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidenybai%2Fmillion/lists"}