Book Review: Dom Scripting

spacer I recently attended an AJAX course in London that, because of the nature of the beast, also included some stuff on DOM scripting. The person running the course was Jeremy "the middle name's Dom, don'tcha know" Keith which, if you know Jeremy or know of him, means that the inclusion of DOM scripting in that course should not have been a surprise. It wasn't. What was, though, was this admission from Mr Keith:

"I wrote a book about DOM scripting but if you can avoid using it, you should avoid using it"

I've actually scribbled that on the inside cover of my copy but strangely it hasn't stopped me picking up the book and reading it through! The point Jeremy was making was that DOM scripting has its place, but when its mixed with AJAX-like technologies, sometimes making lots of finicky changes with DOM script commands is overcomplicating things somewhat, particularly if all you are looking to do is update one specific part of a page, rather than several separate parts at once. In that instance, it might be better to use … wait for it, wait for it … the proprietary innerHTML property.

Ye gads! Did we really hear that? Use something that is not part of any recommendation but, rather unfortunately for all of us geeky standardistas, works rather well across all sorts of browsers? At this point, I'd like to repeat another quote from Jeremy:

"If you're using innerHTML to update content you're kinda just vomiting the content back on to the page."

Nice.

So, enough of the waffle, what about the book? Well, Jeremy's comment was aimed at people who are arguably knowledgeable enough to understand and appreciate when DOM scripting is and when it isn't a good thing to use. But to get to that position you have to understand the basics, and this book is perfect for getting up to speed with the modern usage of JavaScript and how it relates to the web page (or document).

In the book, Jeremy begins by covering off some basic JavaScript. You could probably view that section as a refresher; if you were a complete JavaScript beginner, you would probably want to start with a total beginner's book that spent longer with practical examples of JavaScript (although, admittedly, a total beginner's book on JavaScript might also teach you some nasty habits that Jeremy would then have to put you right on!).

After the refresher, Jeremy starts to knuckle down and introduce the DOM – or Document Object Model. This is the 'tree' that represents all the elements that you find on a web page and using JavaScript and the DOM together it's possible to make some fairly drastic changes to a page, either after it has loaded or when a certain action takes place, such as a keypress, hovering over an element and so on. Sounds like DHTML, no? Well, yes, it basically is, but DHTML got a bad rep because at the time the term was defined, the various browsers out there had wildly different interpretations of the Dom and JavaScript causing all sorts of interoperability issues. That's no longer the case, and now DOM scripting (name changed by deed poll to avoid embarrassing connotations with the past) is a wonderful tool to have at your disposal.

The book contains examples for usage such as an image gallery and an animated slideshow, accompanied by an example web site. There is also some coverage of using DOM scripting to enhance forms, although I admit that I would have liked to see a whole chapter devoted to that aspect – maybe something to consider for a second edition, Jeremy?

An important concept that is touched on at the end of the book is the idea of 'Hijax', or 'hijacking AJAX calls'. In other words, allowing a web page to work when AJAX technologies are not available for whatever reason (scripting disabled/not available, script blocking firewalls stopping updates to page content etc). Again, like the forms section, this is something that could be greatly expanded upon as I really feel that AJAX (which may or may not include some DOM scripting) is one of the biggest hurdles for web accessibility in a long time, and in the rush to implement something cool many people are causing those with specific needs to trip over those hurdles in a variety of different ways.

So, overall I think this is a great book and if, like myself, you have found your JavaScript languishing in recent years through underuse and want to re-discover how it can be used to great effect – but in an accessible and uninvasive way – then this is well worth putting on your bookshelf.

 
Rating (out of ten)
Practical advice:
10
Shelf life:
10
Appendices/Reference materials:
7
Appropriateness for beginners:
7
Variety of topics covered:
7
Overall:
9

Factbox
Title Dom Scripting: Web Design with JavaScript
and the Document Object Model
Where to buy Buy from Amazon US, Amazon UK and other locations
Publisher Friends of Ed
Written by     Jeremy Keith
ISBN 1590595335
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.