Over the last few years, Airbnb’s frontend architecture has evolved to keep pace with the rapid advancement happening the JavaScript world. Starting as a humble Rails 2 + Prototype.js app in 2008, the frontend stack powering airbnb.com has gone through a few revisions, including a push towards single-page app architecture with Backbone.js and Handlebars.js, an adventure into isomorphic JavaScript with Rendr (our library for using Node.js to server-render Backbone SPAs), and most recently, a move toward React.js and a re-envisioning of our build pipeline to take advantage of CommonJS, ES6, and a Node.js-based transform system. Spike Brehm, software engineer on the @AirbnbNerds team, will walk through how we approached and executed on these changes. Plus, get excited to see a preview of our new approach to isomorphic JavaScript, allowing us to server-render React components from our Rails app.
Spike Brehm is a software engineer at Airbnb who specializes in building rich web experiences. As a JavaScript nerd, he has spent the last few years shipping web apps and prototyping Airbnb’s front-end stack, experimenting with “isomorphic JavaScript” — apps that have the flexibility to run on both the client and sever using the same codebase.
18. Hitting a Wall with
Backbone&Handlebars
Backbone & Handlebars approach falls apart as UI
components become more dynamic.
No data binding, so have to either:
1. Re-render whole view when model changes
(slow, lose DOM state like focused fields).
2. Drop down to manual DOM manipulation.
20. Airbnb <3 React
React makes it easier to build&maintain stateful UI
components.
React makes it easier to reason about data flow in your
app.
49. 10%
90%
Rails Node.js
…but too hard to share code between server and server—
between Rails and Node.js.
Long tail of features to
rewrite in JavaScript:
1. CSRF tokens
2. Custom headers, i.e.
CDN
3. Middleware
4. Application code
54. Mystique:
Node.js rendering service
for React components
Allows us to render React components on the server
from within Rails.
Built on Iso, tiny utility for isomorphic bootstrapping of
React components.
https://github.com/goatslacker/iso