Remember when we use to “render” websites directly from the backend?Single page applications are cool and catchy, but some times they fall short, for example, when hit by a search engine, and that’s when you start turning to isomorphic javascript applications.in this talk I share our experience gained on the field while turning our frontends form angular SPAs to isomorphic vanillaJS javascript apps with node a a thin active layer on the client side, taking the best form famous frameworks such as angular and react, and making our own mix.
2. Back to the future:
Isomorphic javascript
applications
3. An isomorphic javascript application:
What is an “isomorphic application”
Why did we need one
How did we build it @ Namshi:
Requirements
Choices
What did we actually do
4. Isomorphism
Isomorphism is a very general concept that appears in several areas
of mathematics. The word derives from the Greek iso, meaning
"equal," and morphosis, meaning "to form" or "to shape.”
wolfram.com
http://mathworld.wolfram.com/Isomorphism.html
5. Isomorphic application
It’s a dynamic website capable of generating its html on
both server and client side, virtually using the same
exact code in both environments
6. and a website
is a bunch of nicely presented html
with an interactive layer on top
36. New and fashionable…
…we’re eager to try it :)
The virtual DOM looks amazing
Flux (once you get it) seems quite a good idea
37. New and fashionable…
…we’re eager to try it :)
The virtual DOM looks amazing
Flux (once you get it) seems quite a good idea
JSX…
38. New and fashionable…
…we’re eager to try it :)
The virtual DOM looks amazing
Flux (once you get it) seems quite a good idea
JSX…
… but components are a nice idea too!
39. New and fashionable…
…we’re eager to try it :)
The virtual DOM looks amazing
Flux (once you get it) seems quite a good idea
JSX…
… but components are a nice idea too!
and The Internet says it can be isomorphic too!
62. Show me the code!
Server entry point
var app = require('express')();
var tpl = require(‘../shared/tpl');
var url = require('url');
app.get('*', function(req, res) {
var path = url.parse(req.url).pathname;
api.getData(path).then(function(data) {
var html = tpl.render('main.html', data);
res.end(html);
});
});
63. Show me the code!
And it’s client counterpart
var page = require('page');
page('*', function (ctx) {
var path = url.parse(ctx.path).pathname;
dispatcher.broadcast('URL_CHANGE', {url: path});
api.getData(path).then(function (data) {
dispatcher.broadcast('DATA_UPDATE', data);
});
});
page.start();
73. Hey but what about my interaction?
well, according to legend: turns out that back in the 90s
humans were able to use websites simply clicking on links and
without fancy UI wow-effects
74. Hey but what about my interaction?
Interaction We call them: widgets
they react to UI changes
they attach to iso-components
interact with data-nm-*
and use VUE.js