SlideShare a Scribd company logo
Implements
Virtual DOM
: @brn ( )
: 
: Cyberagent RightSegment AI Messenger
: http://abcdef.gets.b6n.ch/
FuelDOM
FuelDOM Reactjs View 
https://github.com/brn/fuel

Virtual DOM
What is virtual dom?
DOM DOM JS 
DOM 
DOM 
DOM 

DOM
What is virtual dom?
DOM node	
DOM node	 DOM node	
DOM node	 DOM node	 DOM node	
Virtual Node	
Virtual Node	 Virtual Node	
Virtual Node	 Virtual Node	 Virtual Node	
DOM tree
VDom Tree
div	
span	 div	
text	 span	 p	
What is virtual dom?
div	
span	 div	
text	 span	 p	
Removed
VDom tree A
VDom Tree B
DOM node	
DOM node	 DOM node	
DOM node	 DOM node	 DOM node	
div	
span	 div	
text	 span	 p	
Removed
What is virtual dom?
VDom tree
Dom Tree
Remove OP
Virtual DOM Implementation
DOM 
Patch 
Tree Edit Distance 

vdom-benchmark 

https://vdom-benchmark.github.io/vdom-benchmark/
Virtual DOM Implementation
Fuel		157628	
React	187506
Virtual DOM Implementation
Virtual DOM Implementation
DOM 


•  
•  DOM 
•  



React JSX
Virtual DOM Implementation
<div>	
		{[1,	2,	3].map(v	=>	<span>{v}</span>)}	
		<span>test</span>	
</div>
React.createClass(‘div’,	{},		
		[1,	2,	3].map(v	=>		
				React.createClass(‘span’,	{},	v)),	
		React.createClass(‘span’,	{},	‘test’)	
)
Virtual DOM Implementation
React.createClass(‘div’,	{},	
		// 		
		[1,	2,	3].map(v	=>	
				React.createClass(‘span’,	{},	v)),	
		// ReactElement ReactElement		
		React.createClass(‘span’,	{},	‘test’)	
)
Virtual DOM Implementation
Virtual DOM Implementation
DOM 

•  Node.firstChild.nodeValue
textContent 

•  textContent 
•  
DOM
Virtual DOM Implementation
vidom Patch 
key
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“4”	 li key=“3”	 li key=“2”	 li key=“1”	
Unmatch
Match
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 4
treeBRightIndex = 4
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“4”	 li key=“3”	 li key=“2”	 li key=“1”	
Unmatch
Match
treeALeftIndex = 0 treeARightIndex = 3
treeBLeftIndex = 1 treeBRightIndex = 4
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“4”	 li key=“3”	 li key=“2”	 li key=“1”	
Unmatch
Match
treeALeftIndex = 0 treeARightIndex = 2
treeBLeftIndex = 2 treeBRightIndex = 4
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“4”	 li key=“3”	 li key=“2”	 li key=“1”	
Unmatch
Match
treeALeftIndex = 0 treeARightIndex = 2
treeBLeftIndex = 2 treeBRightIndex = 4
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“4”	 li key=“3”	 li key=“2”	 li key=“1”	
Match
treeALeftIndex = 0 treeARightIndex = 2
treeBLeftIndex = 2 treeBRightIndex = 4
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“3”	 li key=“1”	 li key=“2”	 li key=“4”	 li key=“5”	
Unmatch
Unmatch
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 4
treeBRightIndex = 4
Match
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“3”	 li key=“1”	 li key=“2”	 li key=“4”	 li key=“5”	
Unmatch
Unmatch
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 3
treeBRightIndex = 3
Match
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“3”	 li key=“1”	 li key=“2”	 li key=“4”	 li key=“5”	
Unmatch
Match
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 2
treeBRightIndex = 2
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“3”	 li key=“1”	 li key=“2”	 li key=“4”	 li key=“5”	
Match
treeALeftIndex = 0
treeBLeftIndex = 1
treeARightIndex = 2
treeBRightIndex = 2
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“3”	 li key=“1”	 li key=“2”	 li key=“4”	 li key=“5”	
Match
treeALeftIndex = 1
treeBLeftIndex = 2
treeARightIndex = 2
treeBRightIndex = 2
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“4”	 li key=“2”	 li key=“3”	 li key=“1”	 li key=“5”	
Unmatch
Unmatch
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 4
treeBRightIndex = 4
Match
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“4”	 li key=“2”	 li key=“3”	 li key=“1”	 li key=“5”	
Unmatch
Match
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 3
treeBRightIndex = 3
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“4”	 li key=“2”	 li key=“3”	 li key=“1”	 li key=“5”	
Unmatch
Unmatch
treeALeftIndex = 0
treeBLeftIndex = 1
treeARightIndex = 2
treeBRightIndex = 3
Match
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“4”	 li key=“2”	 li key=“3”	 li key=“1”	 li key=“5”	
treeALeftIndex = 1
treeBLeftIndex = 1
treeARightIndex = 2
treeBRightIndex = 2
Match
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“4”	 li key=“2”	 li key=“3”	 li key=“1”	 li key=“5”	
treeALeftIndex = 2
treeBLeftIndex = 2
treeARightIndex = 2
treeBRightIndex = 2
Match
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“3”	 li key=“1”	 li key=“4”	 li key=“2”	
Unmatch
Match
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 4
treeBRightIndex = 4
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“3”	 li key=“1”	 li key=“4”	 li key=“2”	
Unmatch
Unmatch
treeALeftIndex = 0
treeBLeftIndex = 1
treeARightIndex = 3
treeBRightIndex = 4
Unmatch
Unmatch
Virtual DOM Implementation
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“1”	 li key=“3”	 li key=“4”	 li key=“2”	
treeALeftIndex = 0
treeBLeftIndex = 0
treeARightIndex = 4
treeBRightIndex = 4
{1: 1, 3: 2, 4: 3, 2: 4} = {key: index}	
Map
Virtual DOM Implementation
Map 
Map 
li key=“1”	 li key=“2”	 li key=“3”	 li key=“4”	 li key=“5”	
li key=“5”	 li key=“1”	 li key=“3”	 li key=“4”	 li key=“2”	
この範囲	
この範囲
Virtual DOM Implementation
Sorted Reversed

KeyMap
Virtual DOM Implementation
React JSX 

React flattenChildren 


ReactElement flyweight

JSX
Virtual DOM Implementation
•  
•  createElement Clone 
•  ReactElement 
Others
Virtual DOM Implementation
DOM 
Recylcer createElement

DOM 


Caches
Virtual DOM Implementation
DOM Map
cloneElement 
createElement 
cloneElement
Virtual DOM Implementation
ReactElement

V8 Map 
Constructor over Object
Virtual DOM Implementation
Fuel							96131	
React						192195	
React-lite	107019
Virtual DOM Implementation


requestAnimationFrame 

Patch
Thank you!

More Related Content

More from Taketoshi 青野健利

ServiceWorkerとES6 Modules時代のTypescript開発考察
ServiceWorkerとES6 Modules時代のTypescript開発考察ServiceWorkerとES6 Modules時代のTypescript開発考察
ServiceWorkerとES6 Modules時代のTypescript開発考察
Taketoshi 青野健利
 
javascriptのデータ構造の話
javascriptのデータ構造の話javascriptのデータ構造の話
javascriptのデータ構造の話
Taketoshi 青野健利
 
V8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパーV8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパー
Taketoshi 青野健利
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
Taketoshi 青野健利
 
JavascriptのGC入門
JavascriptのGC入門JavascriptのGC入門
JavascriptのGC入門
Taketoshi 青野健利
 
V8 Iginition Interpreter
V8 Iginition InterpreterV8 Iginition Interpreter
V8 Iginition Interpreter
Taketoshi 青野健利
 
GraphQL with React
GraphQL with ReactGraphQL with React
GraphQL with React
Taketoshi 青野健利
 
Jspmとtypescriptで開発する
Jspmとtypescriptで開発するJspmとtypescriptで開発する
Jspmとtypescriptで開発する
Taketoshi 青野健利
 
React and-rx
React and-rxReact and-rx
WebWorker and Atomics
WebWorker and AtomicsWebWorker and Atomics
WebWorker and Atomics
Taketoshi 青野健利
 

More from Taketoshi 青野健利 (10)

ServiceWorkerとES6 Modules時代のTypescript開発考察
ServiceWorkerとES6 Modules時代のTypescript開発考察ServiceWorkerとES6 Modules時代のTypescript開発考察
ServiceWorkerとES6 Modules時代のTypescript開発考察
 
javascriptのデータ構造の話
javascriptのデータ構造の話javascriptのデータ構造の話
javascriptのデータ構造の話
 
V8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパーV8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパー
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
 
JavascriptのGC入門
JavascriptのGC入門JavascriptのGC入門
JavascriptのGC入門
 
V8 Iginition Interpreter
V8 Iginition InterpreterV8 Iginition Interpreter
V8 Iginition Interpreter
 
GraphQL with React
GraphQL with ReactGraphQL with React
GraphQL with React
 
Jspmとtypescriptで開発する
Jspmとtypescriptで開発するJspmとtypescriptで開発する
Jspmとtypescriptで開発する
 
React and-rx
React and-rxReact and-rx
React and-rx
 
WebWorker and Atomics
WebWorker and AtomicsWebWorker and Atomics
WebWorker and Atomics
 

Recently uploaded

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

仮想DOMの実装とパフォーマンス