SlideShare uma empresa Scribd logo
JAVASCRIPT, REACT NATIVE &
Performance
@tadeuzagallo
ABOUT ME
@tadeuzagallo
React Native Startup
OVERVIEW
@tadeuzagallo
@tadeuzagallo
React Native's
GOALS
@tadeuzagallo
Hybrid APPS
@tadeuzagallo
Performance Goals
▸ Reduce Memory Usage
▸ Reduce Startup Overhead
@tadeuzagallo
Native
OPTIMISATIONS
@tadeuzagallo
MULTI-THREADED
Initialisation
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
LAZY
Module Initialisation
@tadeuzagallo
@tadeuzagallo
Smarter
BATCHING
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
JavaScript
OPTIMISATIONS
@tadeuzagallo
INLINE/LAZY
Requires
@tadeuzagallo
var alert = require('alert');
// ...
<TouchableHighlight onPress={() => alert('Touched')}>
// ...
</Touchable>
@tadeuzagallo
// ...
<TouchableHighlight onPress={() => require('alert')('Touched')}>
// ...
</Touchable>
@tadeuzagallo
DEAD CODE ELIMINATION
@tadeuzagallo
if (__DEV__) {
require('DebugOnlyModule');
}
const Alert = Platform.OS == 'ios' ?
require('AlertIOS') :
require('AlertAndroid');
@tadeuzagallo
// dev=false&minify=true
// platform=ios
const Alert = require('AlertIOS');
// platform=android
const Alert = require('AlertAndroid');
@tadeuzagallo
AND MORE...Optimise polyfills, extract babel helpers, ...
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
What next?
@tadeuzagallo
@tadeuzagallo
We shape our code
IN TERMS OF THE VM
@tadeuzagallo
@tadeuzagallo
VM
ARCHITECTURE
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
But on iOS...
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
TL;DR
THIRD-PARTY APPS CAN'T JIT ON iOS
@tadeuzagallo
@tadeuzagallo
WHAT ABOUT
Android?
@tadeuzagallo
WE CAN JIT ON Android!
@tadeuzagallo
...BUT IT'S SLOWER*...
@tadeuzagallo
ANDROID SETUP
@tadeuzagallo
Profile, profile and profile
@tadeuzagallo
@tadeuzagallo
Parsing is
EXPENSIVE
@tadeuzagallo
@tadeuzagallo
var hello = "Hello, World!";
var HelloWorld = function() {
return React.createElement('div', null, hello);
};
ReactDOM.render(
React.createElement(HelloWorld),
document.body);
@tadeuzagallo
/* */ var hello = "Hello, World!";
/* */
/* */ var HelloWorld = function() {
/* */ return React.createElement('div', null, hello);
/* */ };
/* */
/* */ ReactDOM.render(
/* */ React.createElement(HelloWorld),
/* */ document.body);
@tadeuzagallo
/* ==> */ var hello = "Hello, World!";
/* */
/* */ var HelloWorld = function() {
/* */ return React.createElement('div', null, hello);
/* */ };
/* */
/* */ ReactDOM.render(
/* */ React.createElement(HelloWorld),
/* */ document.body);
@tadeuzagallo
/* */ var hello = "Hello, World!";
/* */
/* ==> */ var HelloWorld = function() {
/* */ return React.createElement('div', null, hello);
/* */ };
/* */
/* */ ReactDOM.render(
/* */ React.createElement(HelloWorld),
/* */ document.body);
@tadeuzagallo
/* */ var hello = "Hello, World!";
/* */
/* */ var HelloWorld = function() {
/* ==> */ return React.createElement('div', null, hello);
/* */ };
/* */
/* */ ReactDOM.render(
/* */ React.createElement(HelloWorld),
/* */ document.body);
@tadeuzagallo
/* */ var hello = "Hello, World!";
/* */
/* */ var HelloWorld = function() {
/* */ return React.createElement('div', null, hello);
/* */ };
/* */
/* ==> */ ReactDOM.render(
/* */ React.createElement(HelloWorld),
/* */ document.body);
@tadeuzagallo
/* */ var hello = "Hello, World!";
/* */
/* */ var HelloWorld = function() {
/* ==> */ return React.createElement('div', null, hello);
/* */ };
/* */
/* */ ReactDOM.render(
/* */ React.createElement(HelloWorld),
/* */ document.body);
@tadeuzagallo
Pre-parse
CACHE
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
Bytecode
CACHE
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
@tadeuzagallo
Random Access Bundle
@tadeuzagallo
import React, { Component } from 'react';
import { Text, AppRegistry } from 'react-native';
var HelloWorld = () => (
<Text>Hello, World!</Text>
);
AppRegistry.registerComponent('SampleApp', () => HelloWorld);
@tadeuzagallo
__d('ReactComponent', function (global, require, module, exports) { /* ... */ });
__d('react', function (global, require, module, exports) { /* ... */ });
__d('AppRegistry', function (global, require, module, exports) { /* ... */ });
__d('Text', function (global, require, module, exports) { /* ... */ });
__d('react-native', function (global, require, module, exports) { /* ... */ });
__d('SampleApp.js', function (global, require, module, exports) { /* ... */ });
@tadeuzagallo
__d(0, function (global, require, module, exports) { /* ... */ });
__d(1, function (global, require, module, exports) { /* ... */ });
__d(2, function (global, require, module, exports) { /* ... */ });
__d(3, function (global, require, module, exports) { /* ... */ });
__d(4, function (global, require, module, exports) { /* ... */ });
__d(5, function (global, require, module, exports) { /* ... */ });
@tadeuzagallo
{
0: { offset: 139, size: 202 },
1: { offset: 342, size: 255 },
2: { offset: 598, size: 115 },
3: { offset: 714, size: 107 },
4: { offset: 827, size: 131 },
5: { offset: 959, size: 382 }
}
/* global code */0
__d(0, function (global, require, module, exports) { /* ... */ });0
__d(1, function (global, require, module, exports) { /* ... */ });0
__d(2, function (global, require, module, exports) { /* ... */ });0
__d(3, function (global, require, module, exports) { /* ... */ });0
__d(4, function (global, require, module, exports) { /* ... */ });0
__d(5, function (global, require, module, exports) { /* ... */ });0
@tadeuzagallo
// JavaScript
function require(module) {
if (cached[module]) {
return cached[module];
}
if (!factories[module]) {
nativeRequire(module);
}
cached[module] = factories[module]();
}
// Native
void nativeRequire(module) {
evaluate(RandomAccessBundle + offsets[module]);
}
@tadeuzagallo
react-native bundle --entry-file index.ios.js ...
@tadeuzagallo
react-native unbundle --entry-file index.ios.js ...
@tadeuzagallo
Thank you!
@tadeuzagallo

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

React Native: React Meetup 3
React Native: React Meetup 3React Native: React Meetup 3
React Native: React Meetup 3
 
React Native "A Bad Idea Or A Game Changer" at Code Mania 101
React Native "A Bad Idea Or A Game Changer" at Code Mania 101React Native "A Bad Idea Or A Game Changer" at Code Mania 101
React Native "A Bad Idea Or A Game Changer" at Code Mania 101
 
React Native for ReactJS Devs
React Native for ReactJS DevsReact Native for ReactJS Devs
React Native for ReactJS Devs
 
Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016
 
Going Native With React
Going Native With ReactGoing Native With React
Going Native With React
 
Creating books app with react native
Creating books app with react nativeCreating books app with react native
Creating books app with react native
 
What's This React Native Thing I Keep Hearing About?
What's This React Native Thing I Keep Hearing About?What's This React Native Thing I Keep Hearing About?
What's This React Native Thing I Keep Hearing About?
 
Optimizing React Native views for pre-animation
Optimizing React Native views for pre-animationOptimizing React Native views for pre-animation
Optimizing React Native views for pre-animation
 
React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React Alicante
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
React Native - Getting Started
React Native - Getting StartedReact Native - Getting Started
React Native - Getting Started
 
Putting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native BostonPutting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native Boston
 
Hands on react native
Hands on react nativeHands on react native
Hands on react native
 
From zero to hero with React Native!
From zero to hero with React Native!From zero to hero with React Native!
From zero to hero with React Native!
 
Pieter De Baets - An introduction to React Native
Pieter De Baets - An introduction to React NativePieter De Baets - An introduction to React Native
Pieter De Baets - An introduction to React Native
 
React Native
React NativeReact Native
React Native
 
What's New in JHipsterLand - Devoxx Poland 2017
What's New in JHipsterLand - Devoxx Poland 2017What's New in JHipsterLand - Devoxx Poland 2017
What's New in JHipsterLand - Devoxx Poland 2017
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Calabash-android
Calabash-androidCalabash-android
Calabash-android
 
Calabash Andoird + Calabash iOS
Calabash Andoird + Calabash iOSCalabash Andoird + Calabash iOS
Calabash Andoird + Calabash iOS
 

Destaque

React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
Yukiya Nakagawa
 
Understanding Webkit Rendering
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
Ariya Hidayat
 

Destaque (20)

React Native Internals
React Native InternalsReact Native Internals
React Native Internals
 
React native - What, Why, How?
React native - What, Why, How?React native - What, Why, How?
React native - What, Why, How?
 
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
React Native Introduction: Making Real iOS and Android Mobile App By JavaScriptReact Native Introduction: Making Real iOS and Android Mobile App By JavaScript
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
 
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
 
Hardware Acceleration in WebKit
Hardware Acceleration in WebKitHardware Acceleration in WebKit
Hardware Acceleration in WebKit
 
W3CTech美团react专场-React Native 初探
W3CTech美团react专场-React Native 初探W3CTech美团react专场-React Native 初探
W3CTech美团react专场-React Native 初探
 
Meetup React Native
Meetup React NativeMeetup React Native
Meetup React Native
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
React Native for Web
React Native for WebReact Native for Web
React Native for Web
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)
 
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 RevolutionWebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution
 
When to (use / not use) React Native.
When to (use / not use) React Native.When to (use / not use) React Native.
When to (use / not use) React Native.
 
Introduzione a React Native - Alessandro Giannini
Introduzione a React Native - Alessandro GianniniIntroduzione a React Native - Alessandro Giannini
Introduzione a React Native - Alessandro Giannini
 
Understanding Webkit Rendering
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
 
React native sharing
React native sharingReact native sharing
React native sharing
 
React Native
React NativeReact Native
React Native
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
 
React Native GUIDE
React Native GUIDEReact Native GUIDE
React Native GUIDE
 
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React Ecosystem
 

Semelhante a JavaScript, React Native and Performance at react-europe 2016

Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 

Semelhante a JavaScript, React Native and Performance at react-europe 2016 (20)

Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
Introduction to Domain-Driven Design
Introduction to Domain-Driven DesignIntroduction to Domain-Driven Design
Introduction to Domain-Driven Design
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuff
 
A re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiA re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbai
 
Treatment, Architecture and Threads
Treatment, Architecture and ThreadsTreatment, Architecture and Threads
Treatment, Architecture and Threads
 
R57.Php
R57.PhpR57.Php
R57.Php
 
Writing JavaScript that doesn't suck
Writing JavaScript that doesn't suckWriting JavaScript that doesn't suck
Writing JavaScript that doesn't suck
 
Development Principles & Philosophy
Development Principles & PhilosophyDevelopment Principles & Philosophy
Development Principles & Philosophy
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
Introduction to Zend Framework
Introduction to Zend FrameworkIntroduction to Zend Framework
Introduction to Zend Framework
 
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
 
¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
 
Test upload
Test uploadTest upload
Test upload
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 

Último

Último (20)

PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 

JavaScript, React Native and Performance at react-europe 2016