Asked By: Anonymous
I am working on a large web site, and we’re moving a lot of functionality to the client side (Require.js, Backbone and Handlebars stack). There are even discussions about possibly moving all rendering to the client side.
But reading some articles, especially ones about Twitter moving away from client side rendering, which mention that server side is faster / more reliable, I begin to have questions. I don’t understand how rendering fairly simple HTML widgets in JS from JSON and templates is a contemporary browser on a dual core CPU with 4-8 GB RAM is any slower than making dozens of includes in your server side app. Are there any actual real life benchmarking figures regarding this?
Also, it seems like parsing HTML templates by server side templating engines can’t be any faster than rendering same HTML code from a Handlebars template, especially if this is a precomp JS function?
Answered By: Anonymous
There are many reasons:
(usually done in compiled language)
- DOM manipulation is slow, and if you are manipulating it in JS it
results in poor performance. There are ways to overcome this like
preparing your rendering in text then evaluating it, this might in fact gets you as close to server side rendering.
- Some browsers are just too slow, especially old IE