AJAX: back to static HTML pages
AJAX allows for a lot of geeky stuff. I won’t talk about that. What I like particularly about AJAX is that it makes it so easy to serve static pages in complex applications.
Let’s start with an example: I often do sites on which 90% of the pages are static, only a few contain functionality that requires server-interaction, like contact forms, calculators, subscriptions, etc. I always use some kind of framwork for navigation and templating. Sometimes a CMS is appropriate, sometimes I take my hand-rolled, which is XML and Smarty based.
Considering how many pages are static, it would be good to pull the static pages through wget and just display them statically. There is absolutely no need to parse XML, build navigation, and build content on each request for a page that never changes. But that disconnects the 10% of pages where content depends on user input. It is hard to build a elegant solution which knows a ‘render’ mode and a ’serve’ mode.
That’s where AJAX comes into play: if all functionality is AJAX driven, then it becomes easy to render the pages statically, as AJAX allows us to completely separate HTML generation and logic processing server-side. They happen in two different requests.
This does not work with most of the existing AJAX frameworks, as they mangle HTML rendering and AJAX processing, although there is no need at all. It might work with PEAR’s HTML_AJAX, I’ll need to investigate.
Not convinced? Rendering pages statically can be taken to exremes. For example, Saab’s configurator consists only of statically rendered HTML pages. This works, because it does not contain any dynamic elements. Now take the OPEL configurator: it cannot be statically rendered as it contains service boxed, like a finance calculator in which the user can change parameters. But with AJAX, it can still be static: all server-interaction can be made when the page is loaded and when necessary.
AJAX: for real separation of presentation and logic.
February 6th, 2006 at 3:22 pm
Check out HTML_AJAX’s support for JavaScript behaviors, it will even let you keep the JavaScript code out of the html.
http://blog.joshuaeichorn.com/archives/2006/01/24/html_ajax-feature-of-the-week-javascript-behaviors/
February 7th, 2006 at 9:23 am
Joshua,
Thanks for the hint. That looks awsome. I only had a peek at HTML_AJAX a while ago, and it looked very clean. Looks like the first impression was right.