New free article – From DHTML to DOM scripting
Wednesday, March 29th, 2006 at 5:55 pmI just published a new longer article (40 pages) trying to explain the differences between DHTML and DOM scripting. The article explains what DHTML, the DOM and DOM scripting is and shows how to create a web page with dynamic elements like tabs, a slide show and a big product shot in both ways.
- Check From DHTML to DOM scripting now
The DHTML explanation is annotated with explanations why some of the techniques are a bad idea and the DOM scripting version explains why some of the assets are good ideas. As a summary:
DHTML issues:
- Script dependence – Users without JavaScript get stuck or get elements that only work with JavaScript but don’t do anything for them.
- Mixing presentation and functionality – If you want to change the look of the effect you need to hack around the JavaScript.
- Assuming functionality without testing for it – what it says
- Keeping maintenance JavaScript based – Maintainers are expected to change the script when they want to change the effect, and search through the whole script.
- Mixing HTML and JavaScript – what it says
- Blaming the user – Users get messages like “you cannot use this as your browser doesn’t support it, update your browser” instead of just not getting the functionality if it is not 100% necessary.
- Taking over the document – one onload to rule them all
DOM scripting assets:
- Progressive Enhancement – check if things are available, then apply those dependent on them
- Ease of maintenance – keep the maintenance as easy as possible via dynamic CSS classes and properties at the beginning of the script
- Separation of Presentation and Behaviour – add dynamic classes instead of changing the style collection
- Separation of Structure and Behaviour – use dynamic event handlers and generated elements instead of onclick and NOSCRIPT
- Using modern event handling – more than one onload please
- Avoiding clashes with other scripts – avoid global variables and encapsulate functions as methods in an object
Of course, you can disagree :-)