Hacker News new | ask | show | jobs
by jameswyse 4580 days ago
I find the best approach is to render the initial view server-side and then render any future requests client-side with data from your API. That way your site will be super fast and can be indexed by search engines.

If you're using node.js then you can even use the exact same template rendering code.

2 comments

Did you read the article? They specifically address this:

This means it might well be faster from an end-to-end perspective to send JavaScript+HTML than JSON with client-side templates, depending on the complexity of those templates and the computational power of the client. This is double so because the server-generated templates can often be cached and shared amongst many users (see Russian Doll caching).

You can even use the same templates on the server and client with python server side using Jinja2 and Nunjucks.