Thursday, June 19, 2008

Hijax: Progressive Enhancement with Ajax

Web pages vs. applications ...

"When I was originally writing the DOM Scripting book, its scope was very clear - it was to be an introductory work on JavaScript and the Document Object Model, with an emphasis on best practices. I made a conscious decision not to cover advanced topics like XMLHttpRequest.

But as the writing of the book progressed, Ajax really began to explode. It became clear that I’d have to at least mention the subject, even if I couldn’t cover it in detail. That’s where the book’s final chapter came from.

I felt it was important to hammer home a point I had been trying to make throughout the book, namely that progressive enhancement automatically guarantees graceful degradation. I was concerned that developers who agreed with this principle when it came to CSS or DOM Scripting, cast it aside as soon as Ajax was involved.

“It’s a whole different ball game”, cried the excited developers. “See, these aren’t web pages, it’s a web application.”

But most applications, web-based or not, still work on a document basis. Think Word, email, even Photoshop. You’re still manipulating a file. What Ajax brings to the table is the ability to manipulate a file on the Web without constantly refreshing the whole thing.

Web applications and web pages are not mutually exclusive. One is built on top of the other. Far too often, the builders of web applications concentrate on the “application” part to the detriment of the “web” part.

There are many definitions of the Ajax methodology floating around, but mine is very basic indeed:

The ability to update part of a page instead of the whole page

(and, yes, I do realise that, by that definition, framesets and Flash fall under the Ajax umbrella.)

Now, depending on how your mind works, you could apply that definition in one of two ways. You could say:

“What’s the big deal? Ajax is just the ability to update part of a page instead of the whole page.”

Or you could say:

“OMG! With Ajax, you can update part of the page instead of the whole page!”

Both viewpoints are valid. The value of Ajax lies in-between. It lies in the ability to appreciate the power that comes with being able to make asynchronous requests to the server without a page refresh, while at the same time always bearing in mind that you are still dealing with documents.

If that’s your mindset, then building Ajax applications that degrade gracefully becomes a no-brainer. I wrote some time back about progressive enhancement with Ajax. It’s a very simple idea:

1. First, build an old-fashioned website that uses hyperlinks and forms to pass information to the server. The server returns whole new pages with each request.
2. Now, use JavaScript to intercept those links and form submissions and pass the information via XMLHttpRequest instead. You can then select which parts of the page need to be updated instead of updating the whole page.

I’ve even got a nice shiny buzzword for this technique: Hijax."    (Continued via UIE, Jeremy Keith)    [Usability Resources]


Post a Comment

<< Home

<< Home