Building a Simple Virtual DOM from Scratch - Jason Yu
Video Statistics and Information
Channel: Tech Talks YLD
Views: 17,736
Rating: 4.9537573 out of 5
Keywords: Meetup, Tech Talk, YLD, yld meetup, jason yu, manchester web meetup
Id: 85gJMUEcnkc
Channel Id: undefined
Length: 43min 16sec (2596 seconds)
Published: Wed Dec 05 2018
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Great energy, knows his environment, types like a champ. A+.
Anyone knows what is the IDE he's using?
Holy shit, this guy is awesome
Reconciliation is unnecessary overhead with more modern approaches like lit-html. The way it works is that instead of updating a VDOM and then walking it and checking where it differs from the real DOM (reconciliation), it creates the DOM tree (efficiently, using
<template>
) and then just compares the current arguments to the previous using===
and updates the nodes directly if the arguments differ. For example:html`<span>${123}</span>` // tagged template literal, returns a template
The
html
tag function receives["<span>", "</span>"]
(roughly) as the first argument and123
as the second, and it caches these globally, and maps to a<template>
for instantiating the DOM quickly next time it's called with the same markup. Callinghtml`<span>${123}</span>
produces the same template as the cached one, so it knows not to re-render it; if the arguments change, it updates the placeholders in the template instead of re-building the DOM.Sorry if the explanation was a bit convoluted, but the gist is that VDOM was a good idea but is essentially obsolete, and React hasn't caught up yet, and probably isn't straightforwardly adaptable to the newer approach.
This is really good!