Obtrusive JavaScript

We all know what the expression unobtrusive JavaScript actually means, but it's not clear what obtrusive means.

Web developers usually think that separating markup from behavior is the only aspect to consider when dealing with a proper JavaScript coding. But there's another aspect that is often overlooked: accessibility.

Obtrusive JavaScript is writing our code disregarding the accessibility issues that may arise during the development process. In a nutshell, there are browsers that don't support JavaScript at all (such as Lynx, a textual browser). For example, if you create an Ajax feed reader on your pages by injecting the parsed XML file into the DOM, be aware of the fact that nothing will be rendered in a browser that doesn't support JavaScript.

You should always make sure that JavaScript is not used to handle information that are relevant for a proper understanding of your content or, even more important, that JavaScript is not used to create relevant content. In other words, you should use JavaScript only to manage accessory information.

Ask yourself this question: is this content or information necessary to understand or use my site? If not, you can use JavaScript for that purpose. Remember that accessibility is really important and can make our sites a better place for people with disabilities. And, of course, a better place for the whole web community.

Leave a Reply

Note: Only a member of this blog may post a comment.