Saturday, 17 August 2013

Generate all HTML with JavaScript

Generate all HTML with JavaScript

I am making a Web application, and I'm wondering how far I should take
JavaScript use.
It's a simple application that could be made in one page, and thus appear
"app-like" and quickly responsive (using direct DOM manipulation combined
with AJAX).
I see three general ways I can take this:
A) Generate all HTML on the server, do minor DOM manipulation in
JavaScript, use AJAX to post smaller changes to the server, and reload the
page for larger changes.
B) Generate all HTML on the server, but reload the page less, and instead
use more AJAX to have the server return ready-prepared HTML to insert into
various .
C) Generate all HTML in JavaScript, and have the server return nothing but
JSON objects with data to insert into the HTML.
The reason I'm curious about option C, is that it would give an
interesting MVC feel to things. The server does the Model, and the client
does the View.
Please note that clients lacking JavaScript is not an issue, and I would
use a JavaScript framework to ensure browser compatibility.
Does anyone have positive experiences with this that smoothened the
development process? Is this maybe an established method that has a
specific name, even?

No comments:

Post a Comment