SlideShare a Scribd company logo
Incremental DOM
and
Recent Trend of Frontend Development
2016.3.23
Akihiro Ikezoe
1
• Groupware Developer
• Frontend Team
• Troubleshooting Performance Problems
• Log Analysis
• Recently Interests
• Elasticsearch, Embulk, Kibana
Rx, Kotlin, Scala, AngularJS
About me
2
Today's Contents
• DOM Manipulation
• AngularJS
• Virtual DOM (React)
• Incremental DOM
• Architecture
• Server Client
• Component
• Flux
3
DOM MANIPULATION
4
Rendering on a Browser
Parse
HTML
Parse
HTML
Generate
DOM Tree
Generate
DOM Tree
Generate
Render Tree
Generate
Render Tree
LayoutLayout
PaintPaint
Server
HTML
Parse
CSS
Parse
CSS
Generate
CSSOM Tree
Generate
CSSOM Tree
CSS
5
DOM (Document Object Model)
html
head
title
[text]
body
h1
[text]
input ul
li
li
li
<html>
<head>
<title>sample</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>title</h1>
<input type="text">
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
</body>
</html>
<html>
<head>
<title>sample</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>title</h1>
<input type="text">
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
</body>
</html>
HTML
6
Dynamic Page via JavaScript
• Adding, Removing, or
Updating DOM nodes via
JavaScript.
• Reflow: Recalculate Layout
for parts of the Render
Tree.
• Repaint: Update parts of
the Screen.
Parse
HTML
Parse
HTML
Generate
DOM Tree
Generate
DOM Tree
Generate
Render Tree
Generate
Render Tree
LayoutLayout
PaintPaint
JavaScript
Change DOM Tree
7
DOM Manipulation
• DOM API
• Two-Way Data Binding
• Virtual DOM
• Incremental DOM
8
DOM API
• Problems
• DOM can be changed from anywhere.
→ So to speak, Global Variables.
• Difficult to understand the relationship JavaScript and HTML.
Low Maintainable
<input type="text" id="in_el">
<div id="out_el"></div>
<input type="text" id="in_el">
<div id="out_el"></div>
HTML
window.onload = function() {
var inputEl = document.getElementById('in_el');
var outputEl = document.getElementById('out_el');
inputEl.onkeyup = function() {
outputEl.innerText = inputEl.value;
};
};
window.onload = function() {
var inputEl = document.getElementById('in_el');
var outputEl = document.getElementById('out_el');
inputEl.onkeyup = function() {
outputEl.innerText = inputEl.value;
};
};
JavaScript
9
Client-Side Frameworks
• jQuery can develop interactive pages, but it is not
maintainable.
• We need framework that can manage large complex
application.
• Many Client-Side Frameworks has been born in last few
years.
• AngularJS, Backbone, Ember, ExtJS, Knockout, Elm, React,
Cycle.js, Vue.js, Aurelia, Mithril
10
Frameworks/Libraries to pick up this time
• AngularJS
• All-in-One Web Application Framework developed by Google.
• Many Features: Data Binding, Directive, DI, Routing, Security, Test, etc.
• Angular 2 has been developed in order to solve the problems of AngularJS 1.x.
• React
• UI Building Library developed by Facebook.
• Using Virtual DOM for DOM Manipulation, JSX for Writing Templates.
• Create the new Concepts such as Flux, CSS in JS.
• Incremental DOM
• DOM Manipulation Library developed by Google.
• It has been developed in order to solve the problems of Virtual DOM.
11
Role of each Frameworks/Libraries
Incremental DOM
AngularJSReact
Virtual DOM
Library for
DOM Manipulation
Library for
UI building
Framework for
Client-Side
Web Application
12
AngularJS 1.x
• Two-Way Data Binding
• Automatic synchronization of data between the model and DOM
• If Model was changed, updates DOM.
• If DOM was changed, updates Model.
<input type="text" ng-model="value">
<div>{{value}}</div>
<input type="text" ng-model="value">
<div>{{value}}</div>
HTML
$scope.value
input
ng-model=“value”
{{value}}
DOM
Model
13
Two-Way Data Binding (Binding Phase)
1. Parse HTML and find binding
targets.
2. Generate $watch expressions
for each binding target.
14
DOM
Model
$watch
$watch
$watch
Two-Way Data Binding (Runtime Phase)
1. Change DOM element via user
operation.
2. Update Model via DOM event.
3. Evaluate all $watch
expressions.
4. If there is change in a
model, update DOM element.
5. Repeat Step 3, 4 until all
changes stabilize.
DOM
Model
$watch
$watch
$watch
15
Dirty Checking
Problem of Dirty Checking
• $watch expression is created for each binding target.
• All $watch expressions are evaluated every time DOM event
fired.
• If you built a complex page (e.g. with > 2000 bindings),
its rendering speed will be slow.
16
Improvement by Angular 2
• Tree of Components
• Change Detection Strategy
• Immutable Objects
• Observable Objects
• 100,000checks / < 10msec
17
React (Virtual DOM)
• React updates the whole UI in the application every time
somewhere in model was changed.
• Using Virtual DOM generated from Model.
• Virtual DOM
• It is not an actual DOM object.
• It is a plain JavaScript object that represents a real DOM
object tree.
• Efficiently Re-rendering by applying the diff generated
from Virtual DOM.
18
Virtual DOM (First Rendering)
Virtual DOMModel
19
Real DOM
RenderCreate
Virtual DOM (Update)
Virtual DOMModel
20
Real DOM
previous
current
Patch
Diff
Apply
Create
Create
Problem of Virtual DOM
• Higher Memory Use
• React generates a new Virtual DOM tree every time of re-
rendering.
21
Incremental DOM
• The approach of Incremental DOM is similar to Virtual DOM.
• Walk along the Virtual DOM Tree and Read DOM Tree to figure out
changes.
• If there is no change: Do nothing.
• If there is: Generate diff and apply it to the Real DOM.
• Reduce Memory Use.
• Not as fast as other libraries. (due to access Real DOM)
22
Incremental DOM
23
Patch
Create
In-Memory DOMModel Real DOM
Meta
Meta
MetaMeta
Meta
Compare
Compare
Compare
Compare
Diff Diff
Apply
Benchmarks
24※ https://auth0.com/blog/2016/01/07/more-benchmarks-virtual-dom-vs-angular-12-vs-mithril-js-vs-the-rest/
Depends on your application…
Template Engine for Incremental DOM
• Incremental DOM is a low level library.
• You can choose to use templating language.
• Closure Templates
• Client and Server Side Template Engine developed by Google.
• Language-Neutral, Secure, Typing.
• JSX
• Template Engine used in React.
• JavaScript syntax extension that looks similar to XML.
• Use babel-plugin-incremental-dom.
25
Conclusion
• Incremental DOM has less Memory usage than Virtual DOM.
• But I think the benefits are not so large.
• If you are using Closure-Templates in Client-Side,
Incremental DOM is a good choice.
26
ARCHITECTURE
27
Change of Web Application Architecture
• Component
• Role of Server-Side and Client-Side
• Flux
28
Component
• DOM Tree can be represented as
Component Tree
• Component
• JavaScript -> Class
• HTML -> JSX
• CSS -> CSS in JS
• Pros of Component
• Readable
• Reusable (in the project)
• Maintainable
29
Class
30
class HelloWorld {
constructor(name) {
this.name = name;
}
getMessage() {
return "Hello, " + this.name;
}
}
class HelloWorld {
constructor(name) {
this.name = name;
}
getMessage() {
return "Hello, " + this.name;
}
}
class HelloWorld {
name:string;
constructor(name:string) {
this.name = name;
}
getMessage():string {
return "Hello, " + this.name;
}
}
class HelloWorld {
name:string;
constructor(name:string) {
this.name = name;
}
getMessage():string {
return "Hello, " + this.name;
}
}
ECMAScript 2015 TypeScript
You must use a transpiler.
(babel, closure-compiler, etc.)
JSX
• JavaScript syntax extension that
looks similar to XML.
• Benefits
• Concise
• Familiar Syntax
• Balanced opening and closing tags.
• ECMAScript 2015 and TypeScript
has Template Strings.
31
class App extends Component {
render() {
return <div>
<Header></Header>
<div className={container}>
{this.props.children}
</div>
</div>;
}
}
class App extends Component {
render() {
return <div>
<Header></Header>
<div className={container}>
{this.props.children}
</div>
</div>;
}
}
JSX
CSS in JS
• Problems with CSS at scale
• Global Namespace
• Dependencies
• Dead Code Elimination
• Minification
• Sharing Constants
• Non-deterministic Resolution
• Isolation
32※ https://speakerdeck.com/vjeux/react-css-in-js
const styles = {
button: {
backgroundColor: '#ff0000',
width: '320px',
padding: '20px',
borderRadius: '5px',
border: 'none',
outline: 'none'
}
};
class Button extends Component {
render() {
return (
<Block textAlign="center">
<button style={styles.button}>
Click me!
</button>
</Block>
);
}
}
const styles = {
button: {
backgroundColor: '#ff0000',
width: '320px',
padding: '20px',
borderRadius: '5px',
border: 'none',
outline: 'none'
}
};
class Button extends Component {
render() {
return (
<Block textAlign="center">
<button style={styles.button}>
Click me!
</button>
</Block>
);
}
}
JSX
CSS Modules
• Problems of CSS in JS
• No support for pseudo-elements,
pseudo-classes, media-queries
and animations.
• No CSS prefix support.
• CSS Modules
• Local Naming
• Composition
• Sharing Between Files
• Single Responsibility Modules
33
import button from './Button.css';
class Button extends Component {
render() {
return (
<Block textAlign="center">
<button style={button}>
Click me!
</button>
</Block>
);
}
}
import button from './Button.css';
class Button extends Component {
render() {
return (
<Block textAlign="center">
<button style={button}>
Click me!
</button>
</Block>
);
}
}
JSX
WebPack
• Bundler for Modules
• Can load parts such as CommonJs, AMD, ES6 modules, CSS, Images,
JSON, Coffeescript, LESS, ...
• Can create multiple chunks.
• Dependencies are resolved.
• Preprocess (e.g. Babel, JSX, CSS Module, etc.)
• We may not require build tools such as Grunt, Gulp.
34
Role of Server-Side and Client-Side
• Server-Side MVC / Client-Side MVC
• Single Page Application
• Server-Side Rendering
• Universal JavaScript
35
Server-Side MVC / Client-Side MVC
36
Model
Controller
View
Browser
Model
Model
Controller
View
Browser
DOM
Manipulation
Client
Server
Client
Server
RequestResponse
RequestResponse
Single Page Application (SPA)
• SPA has ability to re-rendering UI without requiring a
server to retrieve HTML.
• SPA needs a Client-Side routing that allows you to
navigate around a web page, using the HTML5 history API.
• SPA offers native application like experience.
37
Server-Side Rendering
• Problem of Client-Side Rendering
• First Rendering
• SEO
• Preview
• Render the Client-Side Application on Server-Side when a
first Request.
• Implementation of Server-Side Rendering
• Use Node.js
• Use JavaScript Engine each platform (Nashorn, go-duktape, etc.)
• Use PhantomJS (Headless Browser)
38
Universal (Isomorphic) JavaScript
• Sharing code between Server and Client.
• Pros
• Reuse code.
• Server-Side Rendering.
• Cons
• Be limited Server-Side Platform.
• Application may be complex.
• Singleton problem.
• Can’t run parts of code on server.
39
Flux
• Flux is the Application
Architecture for Client-Side Web
Application.
• Flux ensures a unidirectional flow
of data between a system’s
components.
• Flux Implementations.
• Facebook Flux, Flummox, Redux, Reflux,
Freezer, flumpt
40※ http://www.infoq.com/news/2014/05/facebook-mvc-flux
MVC does not scale?
An Implementation of Flux (Redux)
41
Action
Action
Action
Reducer
Reducer
Reducer
Store
Dispatch
Store
Current
New
Create
Apply
Event
View (Component Tree)
Role of classes in Redux
• Action
• Payloads of information
that send data from user
input to the store.
• Like a Command-Class in
Command-Pattern.
• Reducer
• Change Application’s State
in response to Action.
42
• Store
• Holds Application state.
• All application state is
stored as a single object.
• View
• Re-rendering templates
using the Store.
Pros of Redux (Flux)
• Readable
• Clear role of each class
• One-Way Data Flow
• Debuggable
• Redux DevTools
• History of every State and Action Payload.
• Rollback
• Testable
• Store only has state.
• Reducer is pure and doesn’t have any side effects.
• High Maintainability!
43
Conclusion
• Web applications are increasingly complex.
We need some new development process.
• Front-End Development keeps changing fast.
• Browsers Improvement
• ECMAScript/AltJS Improvement
• Frameworks Improvement
• We should keep Learning!
44

More Related Content

What's hot

HTML5, CSS3, and JavaScript
HTML5, CSS3, and JavaScriptHTML5, CSS3, and JavaScript
HTML5, CSS3, and JavaScript
Zac Gordon
 
Leksion 1 hyrje ne xhtml
Leksion 1   hyrje ne xhtmlLeksion 1   hyrje ne xhtml
Leksion 1 hyrje ne xhtmlmariokenga
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
Reem Alattas
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overview
Diacode
 
Build Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsBuild Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponents
Gil Fink
 
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Hamdi Hmidi
 
Front End Best Practices
Front End Best PracticesFront End Best Practices
Front End Best Practices
Holger Bartel
 
HTML5 - Introduction
HTML5 - IntroductionHTML5 - Introduction
HTML5 - Introduction
Davy De Pauw
 
Web components
Web componentsWeb components
Web components
Noam Kfir
 
Javascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITComJavascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITCom
Hamdi Hmidi
 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
ubshreenath
 
Unit 2 dhtml
Unit 2 dhtmlUnit 2 dhtml
Unit 2 dhtml
Sarthak Varshney
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflow
Hamdi Hmidi
 
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)Clément Wehrung
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
Chen-Tien Tsai
 
Flexbox
FlexboxFlexbox
Flexbox
LindsayRec
 
Java script
Java scriptJava script
Java script
19TUIT038KAVIARASUM
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
Andrew Rota
 

What's hot (20)

HTML5, CSS3, and JavaScript
HTML5, CSS3, and JavaScriptHTML5, CSS3, and JavaScript
HTML5, CSS3, and JavaScript
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Leksion 1 hyrje ne xhtml
Leksion 1   hyrje ne xhtmlLeksion 1   hyrje ne xhtml
Leksion 1 hyrje ne xhtml
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overview
 
Build Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsBuild Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponents
 
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
 
Front End Best Practices
Front End Best PracticesFront End Best Practices
Front End Best Practices
 
HTML5 - Introduction
HTML5 - IntroductionHTML5 - Introduction
HTML5 - Introduction
 
Web components
Web componentsWeb components
Web components
 
Javascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITComJavascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITCom
 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
 
Unit 2 dhtml
Unit 2 dhtmlUnit 2 dhtml
Unit 2 dhtml
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflow
 
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
 
Vanjs backbone-powerpoint
Vanjs backbone-powerpointVanjs backbone-powerpoint
Vanjs backbone-powerpoint
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
 
Flexbox
FlexboxFlexbox
Flexbox
 
Java script
Java scriptJava script
Java script
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 

Viewers also liked

Reactive Systems と Back Pressure
Reactive Systems と Back PressureReactive Systems と Back Pressure
Reactive Systems と Back Pressure
Akihiro Ikezoe
 
Reactive
ReactiveReactive
Reactive
Akihiro Ikezoe
 
Embulkを活用したログ管理システム
Embulkを活用したログ管理システムEmbulkを活用したログ管理システム
Embulkを活用したログ管理システム
Akihiro Ikezoe
 
The Australian Cyber Security Growth Network Strategy and Goals
The Australian Cyber Security Growth Network Strategy and GoalsThe Australian Cyber Security Growth Network Strategy and Goals
The Australian Cyber Security Growth Network Strategy and Goals
Australian Cyber Security Growth Network Ltd
 
Red Goldfish - Motivating Sales and Loyalty Through Shared Passion and Purpose
Red Goldfish - Motivating Sales and Loyalty Through Shared Passion and PurposeRed Goldfish - Motivating Sales and Loyalty Through Shared Passion and Purpose
Red Goldfish - Motivating Sales and Loyalty Through Shared Passion and Purpose
Stan Phelps
 
受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話
受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話
受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話
Jumpei Miyata
 
Growth Hacking: Offbeat Ways To Grow Your Business
Growth Hacking: Offbeat Ways To Grow Your BusinessGrowth Hacking: Offbeat Ways To Grow Your Business
Growth Hacking: Offbeat Ways To Grow Your Business
Sujan Patel
 
React for .net developers
React for .net developersReact for .net developers
React for .net developers
macsdickinson
 
Edge Rank y Ruby on Rails
Edge Rank y Ruby on RailsEdge Rank y Ruby on Rails
Edge Rank y Ruby on Rails
Andy Otañez
 
Превышаем скоросные лимиты с Angular 2
Превышаем скоросные лимиты с Angular 2Превышаем скоросные лимиты с Angular 2
Превышаем скоросные лимиты с Angular 2
Oleksii Okhrymenko
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
bensmithett
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 
RubyistのためのSilverlight2
RubyistのためのSilverlight2RubyistのためのSilverlight2
RubyistのためのSilverlight2Akihiro Ikezoe
 
Silverlight2でつくるリッチなTrac用UI
Silverlight2でつくるリッチなTrac用UISilverlight2でつくるリッチなTrac用UI
Silverlight2でつくるリッチなTrac用UIAkihiro Ikezoe
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
Jimit Shah
 
Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
Daiwei Lu
 
Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)
jskvara
 
Closure Toolsの紹介
Closure Toolsの紹介Closure Toolsの紹介
Closure Toolsの紹介Yusuke Amano
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
Grgur Grisogono
 
Zoetrope
ZoetropeZoetrope
Zoetrope
Ellie Buchan
 

Viewers also liked (20)

Reactive Systems と Back Pressure
Reactive Systems と Back PressureReactive Systems と Back Pressure
Reactive Systems と Back Pressure
 
Reactive
ReactiveReactive
Reactive
 
Embulkを活用したログ管理システム
Embulkを活用したログ管理システムEmbulkを活用したログ管理システム
Embulkを活用したログ管理システム
 
The Australian Cyber Security Growth Network Strategy and Goals
The Australian Cyber Security Growth Network Strategy and GoalsThe Australian Cyber Security Growth Network Strategy and Goals
The Australian Cyber Security Growth Network Strategy and Goals
 
Red Goldfish - Motivating Sales and Loyalty Through Shared Passion and Purpose
Red Goldfish - Motivating Sales and Loyalty Through Shared Passion and PurposeRed Goldfish - Motivating Sales and Loyalty Through Shared Passion and Purpose
Red Goldfish - Motivating Sales and Loyalty Through Shared Passion and Purpose
 
受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話
受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話
受入試験を自動化したらDevとQAのフィードバックループがまわりはじめた話
 
Growth Hacking: Offbeat Ways To Grow Your Business
Growth Hacking: Offbeat Ways To Grow Your BusinessGrowth Hacking: Offbeat Ways To Grow Your Business
Growth Hacking: Offbeat Ways To Grow Your Business
 
React for .net developers
React for .net developersReact for .net developers
React for .net developers
 
Edge Rank y Ruby on Rails
Edge Rank y Ruby on RailsEdge Rank y Ruby on Rails
Edge Rank y Ruby on Rails
 
Превышаем скоросные лимиты с Angular 2
Превышаем скоросные лимиты с Angular 2Превышаем скоросные лимиты с Angular 2
Превышаем скоросные лимиты с Angular 2
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
 
RubyistのためのSilverlight2
RubyistのためのSilverlight2RubyistのためのSilverlight2
RubyistのためのSilverlight2
 
Silverlight2でつくるリッチなTrac用UI
Silverlight2でつくるリッチなTrac用UISilverlight2でつくるリッチなTrac用UI
Silverlight2でつくるリッチなTrac用UI
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
 
Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)
 
Closure Toolsの紹介
Closure Toolsの紹介Closure Toolsの紹介
Closure Toolsの紹介
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
 
Zoetrope
ZoetropeZoetrope
Zoetrope
 

Similar to Incremental DOM and Recent Trend of Frontend Development

JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
Speedment, Inc.
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
Malin Weiss
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
koppenolski
 
Building Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsBuilding Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsAndrew Ferrier
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
Marco Breveglieri
 
dmBridge & dmMonocle
dmBridge & dmMonocledmBridge & dmMonocle
dmBridge & dmMonocle
University of Nevada, Las Vegas
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground Floor
Katie Weiss
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
chomas kandar
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
Speedment, Inc.
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
Speedment, Inc.
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profilingOpen Academy
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Máté Nádasdi
 
Introduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptIntroduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScript
Jakob Torp
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
Frank La Vigne
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
Chris Love
 
Effective websites development
Effective websites developmentEffective websites development
Effective websites development
Devexperts
 
Web Tools for GemStone/S
Web Tools for GemStone/SWeb Tools for GemStone/S
Web Tools for GemStone/S
ESUG
 

Similar to Incremental DOM and Recent Trend of Frontend Development (20)

JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
Javascript for Wep Apps
Javascript for Wep AppsJavascript for Wep Apps
Javascript for Wep Apps
 
Building Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsBuilding Real-World Dojo Web Applications
Building Real-World Dojo Web Applications
 
DOM Structure
DOM StructureDOM Structure
DOM Structure
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
dmBridge & dmMonocle
dmBridge & dmMonocledmBridge & dmMonocle
dmBridge & dmMonocle
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground Floor
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profiling
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
 
Introduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptIntroduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScript
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Effective websites development
Effective websites developmentEffective websites development
Effective websites development
 
Web Tools for GemStone/S
Web Tools for GemStone/SWeb Tools for GemStone/S
Web Tools for GemStone/S
 

Recently uploaded

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 

Recently uploaded (20)

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 

Incremental DOM and Recent Trend of Frontend Development

  • 1. Incremental DOM and Recent Trend of Frontend Development 2016.3.23 Akihiro Ikezoe 1
  • 2. • Groupware Developer • Frontend Team • Troubleshooting Performance Problems • Log Analysis • Recently Interests • Elasticsearch, Embulk, Kibana Rx, Kotlin, Scala, AngularJS About me 2
  • 3. Today's Contents • DOM Manipulation • AngularJS • Virtual DOM (React) • Incremental DOM • Architecture • Server Client • Component • Flux 3
  • 5. Rendering on a Browser Parse HTML Parse HTML Generate DOM Tree Generate DOM Tree Generate Render Tree Generate Render Tree LayoutLayout PaintPaint Server HTML Parse CSS Parse CSS Generate CSSOM Tree Generate CSSOM Tree CSS 5
  • 6. DOM (Document Object Model) html head title [text] body h1 [text] input ul li li li <html> <head> <title>sample</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>title</h1> <input type="text"> <ul> <li>abc</li> <li>def</li> <li>ghi</li> </ul> </body> </html> <html> <head> <title>sample</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>title</h1> <input type="text"> <ul> <li>abc</li> <li>def</li> <li>ghi</li> </ul> </body> </html> HTML 6
  • 7. Dynamic Page via JavaScript • Adding, Removing, or Updating DOM nodes via JavaScript. • Reflow: Recalculate Layout for parts of the Render Tree. • Repaint: Update parts of the Screen. Parse HTML Parse HTML Generate DOM Tree Generate DOM Tree Generate Render Tree Generate Render Tree LayoutLayout PaintPaint JavaScript Change DOM Tree 7
  • 8. DOM Manipulation • DOM API • Two-Way Data Binding • Virtual DOM • Incremental DOM 8
  • 9. DOM API • Problems • DOM can be changed from anywhere. → So to speak, Global Variables. • Difficult to understand the relationship JavaScript and HTML. Low Maintainable <input type="text" id="in_el"> <div id="out_el"></div> <input type="text" id="in_el"> <div id="out_el"></div> HTML window.onload = function() { var inputEl = document.getElementById('in_el'); var outputEl = document.getElementById('out_el'); inputEl.onkeyup = function() { outputEl.innerText = inputEl.value; }; }; window.onload = function() { var inputEl = document.getElementById('in_el'); var outputEl = document.getElementById('out_el'); inputEl.onkeyup = function() { outputEl.innerText = inputEl.value; }; }; JavaScript 9
  • 10. Client-Side Frameworks • jQuery can develop interactive pages, but it is not maintainable. • We need framework that can manage large complex application. • Many Client-Side Frameworks has been born in last few years. • AngularJS, Backbone, Ember, ExtJS, Knockout, Elm, React, Cycle.js, Vue.js, Aurelia, Mithril 10
  • 11. Frameworks/Libraries to pick up this time • AngularJS • All-in-One Web Application Framework developed by Google. • Many Features: Data Binding, Directive, DI, Routing, Security, Test, etc. • Angular 2 has been developed in order to solve the problems of AngularJS 1.x. • React • UI Building Library developed by Facebook. • Using Virtual DOM for DOM Manipulation, JSX for Writing Templates. • Create the new Concepts such as Flux, CSS in JS. • Incremental DOM • DOM Manipulation Library developed by Google. • It has been developed in order to solve the problems of Virtual DOM. 11
  • 12. Role of each Frameworks/Libraries Incremental DOM AngularJSReact Virtual DOM Library for DOM Manipulation Library for UI building Framework for Client-Side Web Application 12
  • 13. AngularJS 1.x • Two-Way Data Binding • Automatic synchronization of data between the model and DOM • If Model was changed, updates DOM. • If DOM was changed, updates Model. <input type="text" ng-model="value"> <div>{{value}}</div> <input type="text" ng-model="value"> <div>{{value}}</div> HTML $scope.value input ng-model=“value” {{value}} DOM Model 13
  • 14. Two-Way Data Binding (Binding Phase) 1. Parse HTML and find binding targets. 2. Generate $watch expressions for each binding target. 14 DOM Model $watch $watch $watch
  • 15. Two-Way Data Binding (Runtime Phase) 1. Change DOM element via user operation. 2. Update Model via DOM event. 3. Evaluate all $watch expressions. 4. If there is change in a model, update DOM element. 5. Repeat Step 3, 4 until all changes stabilize. DOM Model $watch $watch $watch 15 Dirty Checking
  • 16. Problem of Dirty Checking • $watch expression is created for each binding target. • All $watch expressions are evaluated every time DOM event fired. • If you built a complex page (e.g. with > 2000 bindings), its rendering speed will be slow. 16
  • 17. Improvement by Angular 2 • Tree of Components • Change Detection Strategy • Immutable Objects • Observable Objects • 100,000checks / < 10msec 17
  • 18. React (Virtual DOM) • React updates the whole UI in the application every time somewhere in model was changed. • Using Virtual DOM generated from Model. • Virtual DOM • It is not an actual DOM object. • It is a plain JavaScript object that represents a real DOM object tree. • Efficiently Re-rendering by applying the diff generated from Virtual DOM. 18
  • 19. Virtual DOM (First Rendering) Virtual DOMModel 19 Real DOM RenderCreate
  • 20. Virtual DOM (Update) Virtual DOMModel 20 Real DOM previous current Patch Diff Apply Create Create
  • 21. Problem of Virtual DOM • Higher Memory Use • React generates a new Virtual DOM tree every time of re- rendering. 21
  • 22. Incremental DOM • The approach of Incremental DOM is similar to Virtual DOM. • Walk along the Virtual DOM Tree and Read DOM Tree to figure out changes. • If there is no change: Do nothing. • If there is: Generate diff and apply it to the Real DOM. • Reduce Memory Use. • Not as fast as other libraries. (due to access Real DOM) 22
  • 23. Incremental DOM 23 Patch Create In-Memory DOMModel Real DOM Meta Meta MetaMeta Meta Compare Compare Compare Compare Diff Diff Apply
  • 25. Template Engine for Incremental DOM • Incremental DOM is a low level library. • You can choose to use templating language. • Closure Templates • Client and Server Side Template Engine developed by Google. • Language-Neutral, Secure, Typing. • JSX • Template Engine used in React. • JavaScript syntax extension that looks similar to XML. • Use babel-plugin-incremental-dom. 25
  • 26. Conclusion • Incremental DOM has less Memory usage than Virtual DOM. • But I think the benefits are not so large. • If you are using Closure-Templates in Client-Side, Incremental DOM is a good choice. 26
  • 28. Change of Web Application Architecture • Component • Role of Server-Side and Client-Side • Flux 28
  • 29. Component • DOM Tree can be represented as Component Tree • Component • JavaScript -> Class • HTML -> JSX • CSS -> CSS in JS • Pros of Component • Readable • Reusable (in the project) • Maintainable 29
  • 30. Class 30 class HelloWorld { constructor(name) { this.name = name; } getMessage() { return "Hello, " + this.name; } } class HelloWorld { constructor(name) { this.name = name; } getMessage() { return "Hello, " + this.name; } } class HelloWorld { name:string; constructor(name:string) { this.name = name; } getMessage():string { return "Hello, " + this.name; } } class HelloWorld { name:string; constructor(name:string) { this.name = name; } getMessage():string { return "Hello, " + this.name; } } ECMAScript 2015 TypeScript You must use a transpiler. (babel, closure-compiler, etc.)
  • 31. JSX • JavaScript syntax extension that looks similar to XML. • Benefits • Concise • Familiar Syntax • Balanced opening and closing tags. • ECMAScript 2015 and TypeScript has Template Strings. 31 class App extends Component { render() { return <div> <Header></Header> <div className={container}> {this.props.children} </div> </div>; } } class App extends Component { render() { return <div> <Header></Header> <div className={container}> {this.props.children} </div> </div>; } } JSX
  • 32. CSS in JS • Problems with CSS at scale • Global Namespace • Dependencies • Dead Code Elimination • Minification • Sharing Constants • Non-deterministic Resolution • Isolation 32※ https://speakerdeck.com/vjeux/react-css-in-js const styles = { button: { backgroundColor: '#ff0000', width: '320px', padding: '20px', borderRadius: '5px', border: 'none', outline: 'none' } }; class Button extends Component { render() { return ( <Block textAlign="center"> <button style={styles.button}> Click me! </button> </Block> ); } } const styles = { button: { backgroundColor: '#ff0000', width: '320px', padding: '20px', borderRadius: '5px', border: 'none', outline: 'none' } }; class Button extends Component { render() { return ( <Block textAlign="center"> <button style={styles.button}> Click me! </button> </Block> ); } } JSX
  • 33. CSS Modules • Problems of CSS in JS • No support for pseudo-elements, pseudo-classes, media-queries and animations. • No CSS prefix support. • CSS Modules • Local Naming • Composition • Sharing Between Files • Single Responsibility Modules 33 import button from './Button.css'; class Button extends Component { render() { return ( <Block textAlign="center"> <button style={button}> Click me! </button> </Block> ); } } import button from './Button.css'; class Button extends Component { render() { return ( <Block textAlign="center"> <button style={button}> Click me! </button> </Block> ); } } JSX
  • 34. WebPack • Bundler for Modules • Can load parts such as CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... • Can create multiple chunks. • Dependencies are resolved. • Preprocess (e.g. Babel, JSX, CSS Module, etc.) • We may not require build tools such as Grunt, Gulp. 34
  • 35. Role of Server-Side and Client-Side • Server-Side MVC / Client-Side MVC • Single Page Application • Server-Side Rendering • Universal JavaScript 35
  • 36. Server-Side MVC / Client-Side MVC 36 Model Controller View Browser Model Model Controller View Browser DOM Manipulation Client Server Client Server RequestResponse RequestResponse
  • 37. Single Page Application (SPA) • SPA has ability to re-rendering UI without requiring a server to retrieve HTML. • SPA needs a Client-Side routing that allows you to navigate around a web page, using the HTML5 history API. • SPA offers native application like experience. 37
  • 38. Server-Side Rendering • Problem of Client-Side Rendering • First Rendering • SEO • Preview • Render the Client-Side Application on Server-Side when a first Request. • Implementation of Server-Side Rendering • Use Node.js • Use JavaScript Engine each platform (Nashorn, go-duktape, etc.) • Use PhantomJS (Headless Browser) 38
  • 39. Universal (Isomorphic) JavaScript • Sharing code between Server and Client. • Pros • Reuse code. • Server-Side Rendering. • Cons • Be limited Server-Side Platform. • Application may be complex. • Singleton problem. • Can’t run parts of code on server. 39
  • 40. Flux • Flux is the Application Architecture for Client-Side Web Application. • Flux ensures a unidirectional flow of data between a system’s components. • Flux Implementations. • Facebook Flux, Flummox, Redux, Reflux, Freezer, flumpt 40※ http://www.infoq.com/news/2014/05/facebook-mvc-flux MVC does not scale?
  • 41. An Implementation of Flux (Redux) 41 Action Action Action Reducer Reducer Reducer Store Dispatch Store Current New Create Apply Event View (Component Tree)
  • 42. Role of classes in Redux • Action • Payloads of information that send data from user input to the store. • Like a Command-Class in Command-Pattern. • Reducer • Change Application’s State in response to Action. 42 • Store • Holds Application state. • All application state is stored as a single object. • View • Re-rendering templates using the Store.
  • 43. Pros of Redux (Flux) • Readable • Clear role of each class • One-Way Data Flow • Debuggable • Redux DevTools • History of every State and Action Payload. • Rollback • Testable • Store only has state. • Reducer is pure and doesn’t have any side effects. • High Maintainability! 43
  • 44. Conclusion • Web applications are increasingly complex. We need some new development process. • Front-End Development keeps changing fast. • Browsers Improvement • ECMAScript/AltJS Improvement • Frameworks Improvement • We should keep Learning! 44