Hacker News new | comments | show | ask | jobs | submit login

So. Write your templates in your server-side templating language. That way you can serve full html for initial page loads and compiled-to-javascript versions to allow Ajax updates.

Something like this: https://github.com/comolongo/Yz-Javascript-Django-Template-C...

Thinking about this some more and here's me clarifying things for myself...

There's basically 4 strategies:

1. Give the client a full html page

2. Give the client pre-rendered html snippets

3. Give the client javascript that can render html and replace values without having to do much computation

4. Make the client do the template rendering probably using a library such as mustache.


1. Should be the default and the fallback for dumb devices such as spiders and old browsers

2. Is ideal if the page doesn't change much - typical content heavy sites. You have to have proper urls and history management though.

3. is optimal for "it's an app not a website"

4. is only OK if you know your clients have plenty of CPU to spare. So not mobile basically...


It would be nice to add a layer on top of this that did partial page updates, managed the json views and the history push-state too.

It might be possible to have code where you just transparently wrote normal server-side views and the framework intelligently decided whether to render on the server or client and handled all the plumbing for you.


Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact