2. Denis Izmaylov
• 15 years of Software and Web
development experience
• The last 5 years focused exclusively on
Front-end, Node.js and architecture
• Created 10+ projects, including Single
Page Applications, high-load and React
• Commiter to Redux, webpack and koa
• Speaker at HighLoad++ 2015, MoscowJS
• The author of “Application and Universal
Components” and other articles
, CEO
3. Why should we stop
developing classic
Single Page Applications?
40. Isomorphic Applications
By isomorphic we mean that any
given line of code (with notable
exceptions) can execute both on
the client and the server.
Charlie Robbins,
18 Oct 2011
50. Server-Side Rendering
• Build HTML on Front-end Server
• Render page in user browser
immediately, before it loads JavaScript
• When JavaScript will be loaded,
React will add event handlers only
• It’s very fast
50
51. Server-Side Rendering
Example code for Server-Side:
import ReactDOMServer from 'react-dom/server';
import Application from './components/application';
const body = ReactDOMServer.renderToString(
<Application />
);
51
52. Server-Side Rendering
1. Visitors see a page immediately
2. No additional requests to load data
3. The page could work even without JS
4. Full URL-navigation
5. Meta-tags for SEO and SMM
6. This way keeps all JavaScript features
52
57. Server-Side Rendering
That’s super when we have all data for response:
import ReactDOMServer from 'react-dom/server';
import Application from './components/application';
const initialState = { siteName: 'Startup Makers' };
const body = ReactDOMServer.renderToString(
<Application state={initialState} />
);
57
58. Server-Side Rendering
That’s super when we have all data for response:
import ReactDOMServer from 'react-dom/server';
import Application from './components/application';
const initialState = { siteName: 'Startup Makers' };
const body = ReactDOMServer.renderToString(
<Application state={initialState} />
);
What if we have to
load it async?
58
59. Server-Side Rendering
How to get asynchronous State:
1. Manual for each page
2. Facebook Relay
3. redux-catch-promise
59
60. Asynchronous State
Manual for each page:
• Define which data we have to load for
each page
• Load this data and prepare State
• ReactDOMServer.renderToString()
60
61. Asynchronous State
Facebook Relay:
1. The framework for building data-driven
React applications
2. Declarative. Colocation. Mutations.
3. https://github.com/facebook/relay/
issues/136
4. 1Q2016
61
62. Asynchronous State
redux-catch-promise:
• Redux - state container для React
• Redux: the best for isomorphic apps,
MoscowJS 25
https://youtu.be/Uyk_8WWna6s
• redux-catch-promise is middleware for
Redux
62
63. Asynchronous State
redux-catch-promise:
1. Attach a callback to catch Promise-actions
2. Render the component
3. At the component - create a request to DB (or
other data source) and dispatch a Promise of
that
4. Collect all promises and wait until they will be
finished
5. Render component with data 63
91. Performance
Server rendering is slower with npm react
react/dist/react.min.js
Executing…
Time per request: 38.253 ms
(vs 37.943 ms)
0.08% more
91
92. Performance
Server rendering is slower with npm react
react/dist/react.min.js
Executing…
Time per request: 38.253 ms
(vs 37.943 ms)
0.08% more
FAILED
92
101. Progressive Rendering
• React DOM Stream
• Flushing the Document Early
• “Streams make this library as much as 47% faster
in sending down a full page than
ReactDOM.renderToString”
• Target - 108KB page on Heroku
• Time To First Byte (TTFB) - 55% faster
• https://github.com/aickin/react-dom-stream
101
102. Facebook BigPipe
• Bundle a page during it’s loading
• Assets is loading parallel
• Resistants to errors
103. Facebook BigPipe
• Bundle a page during it’s loading
• Assets is loading parallel
• Resistants to errors
104. Facebook BigPipe
• Bundle a page during it’s loading
• Assets is loading parallel
• Resistants to errors
108. Recommendations
• Find and join local JavaScript
communities
• Improve your English skills
• Read original articles and technical
blogs (Facebook, AirBnB, Netflix, etc)
• Join and integrate Twitter and
GitHub to your life 108
109. Useful Links
1. Supercharging page load (100 Days of Google Dev)
https://youtu.be/d5_6yHixpsQ
2. Making Netflix.com Faster
http://techblog.netflix.com/2015/08/making-netflixcom-
faster.html
3. New technologies for the new LinkedIn home page
https://engineering.linkedin.com/frontend/new-technologies-
new-linkedin-home-page
4. Improving performance on Twitter.com
https://blog.twitter.com/2012/improving-performance-on-
twittercom
5. Scaling Isomorphic Javascript Code
http://blog.nodejitsu.com/scaling-isomorphic-javascript-code/
109
110. Useful Links
6. From AngularJS to React: The Isomorphic Way
https://blog.risingstack.com/from-angularjs-to-react-the-
isomorphic-way/
7. Isomorphic JavaScript: The Future of Web Apps
http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/
8. React server side rendering performance
http://www.slideshare.net/nickdreckshage/react-meetup
9. The Lost Art of Progressive HTML Rendering
http://blog.codinghorror.com/the-lost-art-of-progressive-html-
rendering/
10. Extract and inline Critical Path CSS in HTML pages
https://github.com/addyosmani/critical
110