Use AJAX scripting responsibly

Some regular readers may get the impression that I dislike anything related to Ajax and other advanced scripting. I don't. I do however dislike when JavaScript is used inappropriately and without stopping to think about whether it is actually necessary.

I know the feeling you can get when you learn or read about a new trick or technique - you just want to find a problem to apply your new favourite solution to. But a lot of the time the solution fixes a problem that doesn't exist and only creates new, more serious problems, especially when you consider accessibility.

The key is to use scripting to add value for those who can take advantage of it without causing problems for those who, for whatever reason, cannot. I like the term "Progressive Enhancement" since it describes a mindset and a way of using technology that will help you create usable and accessible websites and web applications. Build the basics first and make sure everything (within reason) works without JavaScript, and then use event handlers to inject usability enhancing functionality.

Shaun Inman's article Responsible Asynchronous Scripting contains more good advice for web developers who want or need to use asynchronous scripting when building a web app.

Posted on June 1, 2006 in Quicklinks, JavaScript