Monday, March 31, 2008

Unobtrusive JavaScript

I recently read several articles about the merits of Unobtrusive JavaScript, a programming paradigm that encourages the separation of functionality from structure, content, and presentation. Some key benefits of Unobtrusive JavaScript include:

  • Better accessibility
  • Improved portability
  • Faster development
  • Simpler code maintenance
  • Graceful degradation of functionality

Some scripting event types that developers commonly commingle with document content and structure include:

  • onclick()
  • onfocus()
  • onblur()
  • onmouseover()
  • onmouseout()
  • onload()
  • onchange()
  • onsubmit()

Inline JavaScript functions can be difficult to maintain, especially if there are numerous occurrences of the inline code sprinkled throughout the website or if multiple people work on the same website. This is especially true when Web developers working with WYSIWYG editors make changes to the site, since the WYSIWYG editors have a tendency to mangle code.

No comments: