Archive for the 'javascript' Category

The seven rules of Unobtrusive JavaScript

JavaScript in an unobtrusive manner.  Why it is a good idea to plan and execute your JavaScript in this way. It helps you deliver products faster, with much higher quality and a lot easier maintenance. read more >>

Separating Behavior From Structure

“Separating Behavior from Structure” refers to the practice of maintaining clean semantic HTML markup that is free of any attributes or script that introduces custom behaviors. Any custom behaviors that are introduced into your HTML page should come from external files that unobtrusively attach/bind the behaviors to elements within your semantic markup. Like the practice of separating style from structure, this has several benefits which include:

  • The ability to make incremental modifications to the HTML markup structure or the behavior code independently without having to modify the other.
  • Because the behavior implementation is externalized, it can be shared across multiple HTML pages, so the bandwidth necessary to view these pages is reduced since the files related to the behaviors are downloaded and cached by the browser once. This also results in smaller HTML pages since the behavior code is not duplicated within the actual markup itself.
  • Since the HTML markup is smaller and semantic, it is also easier to read which aids accessibility with screen readers, search engine web crawlers, and browsers or other user agents that don’t necessarily support the behaviors you’ve implemented.

This document will give you a brief introduction of the “unobtrusive javascript” technique and some utilities within Spry that aid with separating behavior from structure.