The Web's leading standards body released a long-delayed recommendation for using scripts in Web pages but urged coders not to rely too heavily on scripting.
In practical terms, the DOM makes it easier to create Web pages with features that are more animated and functional. With scripts, authors can make Web pages process forms, launch pop-up menus and windows, and execute style changes on the fly. Without the DOM, authors would have to code separately for each scripting language to interact with each different browser. The DOM is meant to create a "write once, run everywhere" standard for Web page scripting.
However, W3C staff urged developers to use scripts sparingly, criticizing the development technique as less efficient and accessible than alternative W3C-recommended methods of creating dynamic Web pages.
"The W3C is working on other specifications, including SVG, SMIL, and
XForms, to move some commonly desired behaviors out of scripts," said , a W3C editor. "Scripting has its limitations."
The trouble with scripts, Jacobs said, is that they are less machine-readable or transparent than so-called declarative languages like SVG and SMIL.
"Scripts tend to do useful things, but in a way that's not obvious for machines to understand," Jacobs said. "I don't imagine a world where you could do everything in a nonscripting way, but it's very hard to know exactly what a script does. From the accessibility perspective, if everything is buried in a scripting language, then it's hard to find an alternative presentation of information. It's hard to repurpose the content."
Others at the W3C echoed Jacobs' attitude toward scripting and the DOM.
"Use the DOM the least you can," said , the W3C's DOM activity lead. "If you have an alternative technique to do exactly what you want without using the DOM, then use it. This technology will be more accessible, and it will be easier for someone else to read it."
The DOM has been in progress at the W3C for more than five years. Level
1 came out in 1998, while most of Level 2 came out two years later, in November 2000.
But the part of Level 2 that specified how scripts could interact with
HTML content--as opposed to XML, for example, or style sheets--had such serious bugs that it did not receive the W3C's recommendation until Thursday.
The DOM Level 2 is incompatible with Level 1 and consigns it to the recommendation trash heap, the W3C said.
The W3C "strongly suggests that developers and authors conform to DOM Level 2 HTML," the consortium wrote in its release.
The group, in concert with the United States National Institute of
Standards and Technology (NIST), also updated its free
test suite that developers can use to check their adherence to the standard.