My laptop’s frelled, so I was stuck over the weekend with the only working computer in the house being an older iMac running a minimal installation of OS 9. This was liberating in a way, as I was not often tempted to fill my spare time by using the computer. Still, by Sunday night I really wanted to check my email, but the email that I cared about is on Gmail. The only browser on that machine is IE5, and last I’d tried Gmail didn’t support IE5/Mac, since they generate page content with JavaScript remote scripting techniques that aren’t supported in older browsers (i.e. XMLHttpRequest).

But I gave it a shot anyway, and it worked! If it needs to, Gmail now functions like a traditional web app, reloading the entire page as necessary. If you want to read a message, the whole page gets rebuilt. You can use Gmail with JavaScript disabled. It even works in Netscape 4.8!

Excellent. This is the way I generally prefer to use JavaScript: to enhance application functionality rather than serve as its core. There are all sorts of reasons for this: accessibility comes to mind early on, as well as the general principle of graceful degradation and not leaving your users behind. In some situations this is arguably less true for web applications as the content on web sites — I can imagine any number of cases where you can assume and demand a certain level of capability in your users’ browsers — but it’s still a good principle.

I normally go about this through a process of progressive enhancement: designing first for less capable user agents, then adding functionality for modern browsers. I’m doing this in a project right now: at first I’m breaking out a function into several pages, then once I’ve worked out the process I plan to incorporate remote scripting to simplify the user interface and reduce the number of page calls. If a user’s browser can handle it, and most will be able to, their experience should be improved. If the browser isn’t up to it, users can still do what they need to.

Google turned this around, releasing early Gmail betas as JavaScript-only and with their share accessibility problems. Then they did the graceful degradation work and made the service available to older browsers, and presumably more accessible. That makes perfect sense: Google made a big splash and showed the world the sort of thing that can be done inside a browser interface. This isn’t actually “turning it around,” per se: it’s quite a normal way to go about things. Still, glad to see it happening.

Update: Jeremy Keith weighs in on progressive enhancement.