SlideShare a Scribd company logo
Master Class:
Isomorphic JavaScript

Spike Brehm
@spikebrehm
irst,
introductions.
Spike Brehm
Software Engineer
Airbnb 2.5 years
JavaScript & Ruby

No CS background;
self-taught hacker
My team
My team
My team
Introduce
yourselves.
Wo you are.
Were you work.
Wy you’re here.
Agenda
Wat
...TF is Isomorphic JavaScript?

Wy
...is it relevant to web developers?

How
...can I build isomorphic apps?
WTF is Isomorphic
JavaScript?
JavaScript code that can run
on both the client and server.
A brief note on
“isomorphic”.
You’re using it wrong!
“monomorphic”
“heteromorphic”
“homomorphic”
“multi-platform”
Example, plz.
Example: Underscore.js
var posts = [{
id: 1,
title: 'JavaScript is cool'
}, {
id: 2,
title: 'The Web is the platform'
}];
 
_.pluck(posts, 'title');
// ['JavaScript is cool', 'The Web is the platform']
Ye olde days:
fat-serer, thinclient.
DOM
manipulation

Form
validation

Client
Animations

JavaScript

Serer
Routing
View layer
Application logic
Persistence

Ruby
Python
Java
PHP
Circa 2011:
thin-serer, fatclient.
DOM
manipulation

Form
validation

Client
Animations

JavaScript

Routing
View layer
Application logic

Serer
Persistence

Ruby
Python
Java
PHP
Teh footure:
shared, fat-serer,
fat-client.
DOM
manipulation

Form
validation

Client
Animations

JavaScript

Shared
Routing

JavaScript

View layer
Application logic

Serer
Persistence

Ruby
Python
Java
PHP
Isomorphic
JavaScript can be
environmentagnostic
or
shimmed per
environment .
Environment-agnostic
Does not depend on browserspecific properties (window) or
server-specific properties
(process.env, req.cookies).
Example: Handlebars.js
var template =
'<ul>' 
'{{#each posts}}' 
' <li>{{title}}</li>' 
'{{/each}}' 
'</ul>'
;
 
var templateFn = Handlebars.compile(template)
, html = templateFn({posts: posts});
// <ul>
//
<li>JavaScript is cool</li>
//
<li>The Web is the platform</li>
// </ul>
Shimmed per environment
Provides shims for accessing
environment-specific properties so
module can expose a single API.
window.location.pathname
vs.
req.path
Example: Superagent
superagent
.post('/api/posts.json')
.send({ title: 'Moar JavaScript', body: '...' })
.set('X-Api-KEY', '123456abcdef')
.end(function(response) {
if (response.status === 200) {
console.log("Success!");
} else {
console.error("Error", response.body.error);
}
});
Isomorphic use
cases.
Isomorphic use cases.
• Templating
• Routing
• I18n
• Date

& currency formatting
• Model validation
• API interaction
• ...?
Most of your
favorite libraries
can be used
isomorphically.
• Underscore.js
• Backbone.js
• Handlebars.js
• jQuery
• Moment
• React.js
• Polyglot.js

(I18n)
Wy go to the
trouble?
Performance
Initial pageload speed.

SEO
Crawlable single-page apps.

Maintainability
Reduce code duplication.
Isomorphic
JavaScript is a
spectrum.
Small bits of
view layer or
logic shared

Entire view
layer and app
logic shared
Few
abstractions

Many
abstractions
Simple

Complex
View layer
shared

Entire app
runtime synced
between client
& server
Isomorphic
frameworks.
Mojito
One of the first isomorphic
frameworks.
•
•
•
•

Released by Yahoo! a few years ago.
Full-stack framework; YUI components.
Super-advanced deferred rendering.
Never caught on.
Meteor
Awesome framework for building
real-time apps.
• Full web application framework; has own
•
•
•
•

build system and package manager.
Realtime from the ground up.
Requires MongoDB (or adapter).
No server-side rendering (yet).
All-star dev team.
Rendr
Library for isomorphic Backbone.js
+ Handlebars.js.
•
•
•
•

Render your Backbone apps on the server.
Open-sourced by Airbnb.
Less opinionated than the big frameworks.
Came out of m.airbnb.com.
Building and
bundling.
Browserif
Package up CommonJS modules for
the browser.
Use ‘require()’ in the browser, the
same way you would on the server.
Bundles a module and all its
dependencies.
Browserif

demo
Grunt
Task runner for automating build and
development workflow.
Grunt
• Compile

Handlebars templates
• Run Browserify to package up your
shared app files
• Recompile files and restart Node
server on every change
Any questions thus
far?
Hack time.
Sample Node.js app
Combines a few modules together
for MVP of isomorphic app.

Express.js blog platform
Basic web server with RESTful API.
Handlebars.js
Templating.

Superagent
HTTP requests to API.

Director
Routing HTTP and HTML5.
Tour of the app.
Setting up locally.
Clone the sample app
git clone git@github.com:spikebrehm/
isomorphic-tutorial.git

github.com/spikebrehm/isomorphic-tutorial
Ensure Node >= 0.8.x
$ node --version
v0.10.21

Have to install?
$ brew install node
or
http://nodejs.org
github.com/spikebrehm/isomorphic-tutorial
Install `grunt-cli`
$ npm install grunt-cli -g

github.com/spikebrehm/isomorphic-tutorial
Run `npm install`
$ cd isomorphic-tutorial
$ npm install

github.com/spikebrehm/isomorphic-tutorial
Run the serer!
$ grunt server

View `localhost:3030` in browser

github.com/spikebrehm/isomorphic-tutorial
Let’s add a feature.
Date formatting
Before:
After:

Moment
moment('2013-11-04T17:23:01.329Z').format('LLLL');
// "Monday, November 4 2013 9:23 AM"
Add Moment using NPM
$ npm install moment --save
Create `formatDate`
Handlebars helper
Posted at {{created_at}}
Posted at {{formatDate created_at}}

function formatDate(dateStr) {
return moment(dateStr).format('LLLL');
}
That wasn’t so hard.
Let’s do another.
Create a new post
New page at /posts/new
Form for post data
On submit, POST to the API.
Use JavaScript to intercept the
submit event and POST via XHR.
Moar features!
Markdown formatting
Using Showdown.js.

Swap out templating
Jade, EJS, Underscore, React.js.

Add UI librar

Backbone.js, Angular.js.

Make it pretty

Bootstrap that shit. Responsive?
Towards an
isomorphic future.
JavaScript is the lingua
franca of the Web.
The Web is the platform;
JavaScript provides the runtime.
More reusable solutions;
more small modules.
It will be rare to see a web app
using no server-side JavaScript.
The revolution will come
in the build systems.
Static analysis, conditional builds,
source transforms.
Questions?
Thanks!
@AirbnbNerds
@spikebrehm

More Related Content

PDF
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
PDF
JSConf US 2014: Building Isomorphic Apps
Spike Brehm
 
PDF
Isomorphic JavaScript: #DevBeat Master Class
Spike Brehm
 
PDF
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
Spike Brehm
 
PDF
Isomorphic JavaScript with Nashorn
Maxime Najim
 
PDF
Building Isomorphic JavaScript Apps - NDC 2015
Eirik Vullum
 
PDF
Integrating Browserify with Sprockets
Spike Brehm
 
PDF
Node PDX: Intro to Sails.js
Mike McNeil
 
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
JSConf US 2014: Building Isomorphic Apps
Spike Brehm
 
Isomorphic JavaScript: #DevBeat Master Class
Spike Brehm
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
Spike Brehm
 
Isomorphic JavaScript with Nashorn
Maxime Najim
 
Building Isomorphic JavaScript Apps - NDC 2015
Eirik Vullum
 
Integrating Browserify with Sprockets
Spike Brehm
 
Node PDX: Intro to Sails.js
Mike McNeil
 

What's hot (20)

PDF
Building a Single-Page App: Backbone, Node.js, and Beyond
Spike Brehm
 
PDF
Node, express & sails
Brian Shannon
 
PDF
Isomorphic web application
Oliver N
 
PPTX
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
MarkupBox
 
PPTX
Mvvm knockout vs angular
Basarat Syed
 
KEY
Getting Started with HTML 5 Web workers
Flumes
 
PDF
The Evolution of Airbnb's Frontend
Spike Brehm
 
PDF
Web workers
Surbhi Mathur
 
PDF
Node.js with Express
Gergely Németh
 
PPTX
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Deepu S Nath
 
PDF
Service Worker 201 (en)
Chang W. Doh
 
ODP
WordPress as a Platform - talk to Bristol Open Source Meetup, 2014-12-08
Tim Stephenson
 
PPTX
Workshop Intro: FrontEnd General Overview
Visual Engineering
 
PPTX
Single Page WebApp Architecture
Morgan Cheng
 
PDF
SxSW 2015
Mike McNeil
 
PDF
Tutorial: Develop Mobile Applications with AngularJS
Philipp Burgmer
 
PDF
Sails.js Intro
Nicholas Jansma
 
PPTX
JavaScript Performance (at SFJS)
Steve Souders
 
PDF
Avoiding Common Pitfalls in Ember.js
Alex Speller
 
PDF
JavaScript MV* Framework - Making the Right Choice
Dmitry Sheiko
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Spike Brehm
 
Node, express & sails
Brian Shannon
 
Isomorphic web application
Oliver N
 
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
MarkupBox
 
Mvvm knockout vs angular
Basarat Syed
 
Getting Started with HTML 5 Web workers
Flumes
 
The Evolution of Airbnb's Frontend
Spike Brehm
 
Web workers
Surbhi Mathur
 
Node.js with Express
Gergely Németh
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Deepu S Nath
 
Service Worker 201 (en)
Chang W. Doh
 
WordPress as a Platform - talk to Bristol Open Source Meetup, 2014-12-08
Tim Stephenson
 
Workshop Intro: FrontEnd General Overview
Visual Engineering
 
Single Page WebApp Architecture
Morgan Cheng
 
SxSW 2015
Mike McNeil
 
Tutorial: Develop Mobile Applications with AngularJS
Philipp Burgmer
 
Sails.js Intro
Nicholas Jansma
 
JavaScript Performance (at SFJS)
Steve Souders
 
Avoiding Common Pitfalls in Ember.js
Alex Speller
 
JavaScript MV* Framework - Making the Right Choice
Dmitry Sheiko
 
Ad

Viewers also liked (8)

PPTX
JavaScript, Beyond the Curly Braces
Chicago ALT.NET
 
PPT
Advanced JavaScript
Fu Cheng
 
PDF
Douglas - Real JavaScript
d0nn9n
 
PDF
JavaScript: Advanced Scoping & Other Puzzles
Sencha
 
PDF
03 Advanced JavaScript
Ynon Perek
 
PDF
Advanced Object-Oriented JavaScript
ecker
 
PPTX
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
raja kvk
 
PPT
Advanced Javascript
Adieu
 
JavaScript, Beyond the Curly Braces
Chicago ALT.NET
 
Advanced JavaScript
Fu Cheng
 
Douglas - Real JavaScript
d0nn9n
 
JavaScript: Advanced Scoping & Other Puzzles
Sencha
 
03 Advanced JavaScript
Ynon Perek
 
Advanced Object-Oriented JavaScript
ecker
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
raja kvk
 
Advanced Javascript
Adieu
 
Ad

Similar to General Assembly Workshop: Advanced JavaScript (20)

PPTX
Isomorphic apps
aditya rohilla
 
PPTX
Isomorphic JavaScript – future of the web
Sigma Software
 
PDF
Isomorphic javascript - Uppsala.js #8
Alexander Aivars
 
PPTX
Isomorphic JavaScript with Node, WebPack, and React
Tyler Peterson
 
PDF
Isomorphic js - React in Rails
Shifa Khan
 
PDF
Isomorphic JS - new silver bullet
imevs
 
PDF
«The Grail: React based Isomorph apps framework»​
FDConf
 
PDF
The Grail: React based Isomorph apps framework
Eldar Djafarov
 
PPT
Isomorphic Javascript - nodebr
David Lojudice Sobrinho
 
PDF
Isomorphic Aplication with Javascript
Hengki Sihombing
 
PDF
Modern UI Development With Node.js
Ryan Anklam
 
PPTX
A few good JavaScript development tools
Simon Kim
 
PPTX
Javascript for Wep Apps
Michael Puckett
 
DOCX
How backbone.js is different from ember.js?
SoftProdigy - We know software!
 
PDF
Zepto and the rise of the JavaScript Micro-Frameworks
Thomas Fuchs
 
PDF
Kharkiv JS 2015 - Creating isomorphic applications in React (en)
Viktor Turskyi
 
PDF
"The Grail: React based Isomorph apps framework" Эльдар Джафаров
Fwdays
 
PDF
Survive JavaScript - Strategies and Tricks
Juho Vepsäläinen
 
KEY
20120306 dublin js
Richard Rodger
 
KEY
Let's run JavaScript Everywhere
Tom Croucher
 
Isomorphic apps
aditya rohilla
 
Isomorphic JavaScript – future of the web
Sigma Software
 
Isomorphic javascript - Uppsala.js #8
Alexander Aivars
 
Isomorphic JavaScript with Node, WebPack, and React
Tyler Peterson
 
Isomorphic js - React in Rails
Shifa Khan
 
Isomorphic JS - new silver bullet
imevs
 
«The Grail: React based Isomorph apps framework»​
FDConf
 
The Grail: React based Isomorph apps framework
Eldar Djafarov
 
Isomorphic Javascript - nodebr
David Lojudice Sobrinho
 
Isomorphic Aplication with Javascript
Hengki Sihombing
 
Modern UI Development With Node.js
Ryan Anklam
 
A few good JavaScript development tools
Simon Kim
 
Javascript for Wep Apps
Michael Puckett
 
How backbone.js is different from ember.js?
SoftProdigy - We know software!
 
Zepto and the rise of the JavaScript Micro-Frameworks
Thomas Fuchs
 
Kharkiv JS 2015 - Creating isomorphic applications in React (en)
Viktor Turskyi
 
"The Grail: React based Isomorph apps framework" Эльдар Джафаров
Fwdays
 
Survive JavaScript - Strategies and Tricks
Juho Vepsäläinen
 
20120306 dublin js
Richard Rodger
 
Let's run JavaScript Everywhere
Tom Croucher
 

Recently uploaded (20)

PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
Software Development Company | KodekX
KodekX
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
This slide provides an overview Technology
mineshkharadi333
 
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
Software Development Company | KodekX
KodekX
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 

General Assembly Workshop: Advanced JavaScript