Fireship · @fireship
High-school student makes React a million times faster
Uploaded June 10, 2023 · Length 2:47
Summary
High school student improves React performance by 70% with million JS, a hyper-optimized virtual DOM.
- react performance optimization
- million js
- virtual dom
- javascript framework
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
it is June 10th 2023 and you are
- 0:03
watching the code report there's
- 0:04
millions of great JavaScript Frameworks
- 0:06
in the world today but the most popular
- 0:07
choice is still react even though we
- 0:09
have faster Alternatives like solid
- 0:11
preact and quick that also use jsx one
- 0:14
of react's original Innovations was the
- 0:15
virtual Dom but many modern Frameworks
- 0:17
have moved away from this approach and
- 0:19
Rich Harris the creator of svelte once
- 0:20
called it pure overhead despite this
- 0:22
react will likely still be used on
- 0:24
websites hundreds of years after we're
- 0:25
all dead but today I have some good news
- 0:27
a recent high school graduate named
- 0:29
Aiden by just improved reacts
- 0:31
performance by 70 percent with million
- 0:33
JS which provides a hyper optimized
- 0:35
virtual Dom and chains the original
- 0:37
virtual Dom to the radiator where it
- 0:38
can't cause any problems when I first
- 0:40
saw this my initial thought was no way
- 0:42
there's no way a teenager could
- 0:43
outrender an entire team of top tier
- 0:45
engineers at meta but there are
- 0:46
benchmarks to back up these outrageous
- 0:48
claims like on the gold standard
- 0:50
framework Benchmark it ranks way higher
- 0:51
than react itself and even beats
- 0:53
solid.js and it provides a live demo
- 0:55
where you can compare react and millions
- 0:57
side by side now it's important to point
- 0:58
out that benchmarks don't really
- 1:00
represent real world use cases and the
- 1:02
vast majority of web apps out there will
- 1:03
never get to the point where they have
- 1:05
rendering issues with a JavaScript
- 1:06
framework however it's always fun to do
- 1:08
some premature over optimization anyway
- 1:10
but if you're a highly experienced react
- 1:12
developer you might be wondering what is
- 1:14
the virtual Dom I've never heard of it
- 1:15
well to update things in the UI react
- 1:17
makes a lightweight copy of the Dom
- 1:19
where it can calculate updates faster
- 1:21
and then update everything all at once
- 1:22
it's kind of like finalizing all your
- 1:24
changes on a blueprint before you go
- 1:25
tearing out walls in a building but all
- 1:27
this happens at runtime and there's a
- 1:29
lot of unnecessary work trying to figure
- 1:30
out what changed million JS takes a more
- 1:33
surgical approach by introducing a
- 1:34
compiler that can perform static
- 1:36
analysis to figure out exactly where the
- 1:38
dynamic data is in advance it creates an
- 1:40
edit map to represent the state of the
- 1:42
application which can then determine
- 1:43
what has changed with far less
- 1:44
computation required this approach is
- 1:46
inspired by other Frameworks like svelt
- 1:48
and solid which also rely on a compiler
- 1:50
to achieve these surgical Dom updates
- 1:52
and million was also inspired by the
- 1:54
prior work of a library called block Dom
- 1:56
what's also cool about million is that
- 1:57
it's only four kilobytes and extremely
- 1:59
easy to use use all you do is take an


