Spry

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 scripts that introduce 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 practice 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.

  • The ability to share the behavior implementation across multiple HTML pages, due to the separation of the behaviors.

  • A reduction in the bandwidth necessary to view your pages since the files related to the behaviors are downloaded and cached by the browser only once.

  • An end-result of smaller HTML pages, since the behavior code is not duplicated within the actual markup itself.

  • Clearer, easier to read HTML markup, 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.

The Spry team has provided an extensive document that gives you a brief introduction of the "unobtrusive javascript" technique and some utilities within Spry that aid with separating behavior from structure.

For more information, see the Separating Behavior from Structure article on Adobe Labs.