Back to blog

Back

Back

Javascript

Javascript

The High School Prodigy Who Made React a Million Times Faster

Jun 10, 2023

Jun 10, 2023

Discover the groundbreaking innovation in JavaScript frameworks - Million JS. This tool, developed by a young high school graduate, has managed to boost React's performance by a staggering 70 percent. Learn about the virtual DOM, its limitations, and how Million JS is changing the game.

React, the Undisputed Leader of JavaScript Frameworks

In today's digital world, JavaScript frameworks abound, promising developers a wealth of tools to build seamless user interfaces. The most popular choice among them is React. Its broad adoption is despite the existence of speedier alternatives like Solid, Preact, and Quick that also deploy JSX.

Virtual DOM: A Blessing or a Curse?

React is widely recognized for its pioneering innovation - the virtual DOM. However, recent developments in the technology world hint at a paradigm shift. Some of the modern JavaScript frameworks have started to veer away from the virtual DOM concept, finding it more of a hindrance than a help. Notably, Rich Harris, the creator of Svelte, once tagged it as 'pure overhead'. React, however, continues to enjoy unshakeable popularity, a testament to its resilience and robustness.

Million JS: A Groundbreaking Innovation

But there's more exciting news! A bright young high school graduate, Aiden, has recently tweaked React's performance to boost it by a staggering 70 percent. The tool he used for this feat, Million JS, is an ultra-optimized version of the virtual DOM. Aiden's innovative approach has successfully sidelined the original virtual DOM, rendering it unable to create any performance issues.

A Performance Game-Changer

The first impressions from industry insiders and technology enthusiasts were of skepticism. How could a teenager manage to outperform an entire team of top-notch engineers at Meta? As it turns out, Aiden's audacious claims aren't baseless. Multiple benchmarks, including the highly-regarded Framework Benchmark, vouch for the exceptional performance of Million JS. In fact, it surpasses even Solid.js, an impressive feat by any standard.

Understanding the Virtual DOM

If you're a seasoned React developer, you might be wondering: what exactly is the virtual DOM? In essence, to update things in the user interface, React creates a lightweight copy of the DOM. It calculates the updates faster and then simultaneously applies all changes. This process is analogous to finalizing all modifications on a blueprint before initiating any construction work.

The Million JS Approach

Million JS uses a more precise approach. It introduces a compiler that performs static analysis, enabling it to identify exactly where dynamic data is. This static analysis creates an 'edit map' representing the application's state, which can then determine what has changed with far less computational power required. This technique, inspired by other frameworks like Svelte and Solid, enables surgical DOM updates.

The Practicalities of Using Million JS

One significant advantage of Million JS is its small size - only four kilobytes - and its ease of use. Developers only need to take an existing React component and wrap it inside a block function. This creates a higher order component which blocks out the virtual DOM and lets Million JS take the reins. After the component is mounted, Million JS does all subsequent rendering and change detection on its own.

The Limitations of Million JS

While Million JS may appear as a game-changer, the creator of the project cautions that it's not a panacea for all performance woes. When using blocks, developers need to adhere to a specific set of rules. Failure to follow these guidelines will result in reversion back to React's virtual DOM, thereby nullifying all performance enhancements.

A Glimpse into the Future

In a nutshell, Million JS is an intriguing project that signals hope for future tech advancements. It's a testament to the younger generation's technological prowess, suggesting that they may have the capabilities to reimagine and revamp longstanding technologies like React. After all, there's always room for improvement, and the next leap forward might just be around