Jeremy Keith Interview
Published on October /files/includes/10.css, 2005
Jeremy, Andy and Richard Rutter recently joined forces to form the Web consultancy Clear:left. He took a few minutes (OK, nearly two hours) away from his busy schedule for a chat with us about DOM scripting—the book and the movement.
Jeremy Keith: Originally, it was the desire to do cool stuff like make things whizz around the page or make one thing do something when you clicked on another thing. You can still see my first forays into whizz-bang-whoosh DHTML at http://adactio.com/version1/.
DW: Ha, true. Do you remember the first script you ever wrote?
DW: What would you say makes a really good script?
JK: For me, I think graceful degradation is the most important factor. What that boils down to is that a good script shouldn’t make any assumptions about its environment. Instead, it should investigate the terrain and carry out tasks only when the browser or document are capable of executing the instructions. The obvious example is object detection. Instead of assuming that the browser understands a method you’re going to use, like document.getElementById, you test for its existence before doing anything else in your script. The same approach applies to the document itself. Don’t assume that an element with a certain id exists—check for its existence before trying to manipulate it.
DW: You were one of the first people to use the term “DOM scripting” for what has been traditionally known as DHTML. Why the shift in nomenclature?
JK: Mostly because of the baggage associated with the term DHTML. The term DHTML didn’t originate with developers—it was a marketing buzzword created by the browser vendors. I’m pretty sure that to most developers, the name sounded confusing—like another flavor of HTML… like, say, XHTML.
Also, the kind of scripts that date from the DHTML era (the late ’90s) are fundamentally different than the kind of scripts we would write today. Back then, competing browsers had different document object models. If you wanted to reference an element in Internet Explorer, you had to use document.all. In Netscape, it was document.layers. DHTML, by necessity, involved lots of code-forking to make anything work across browsers.
Nowadays, thanks to the standardized DOM, that kind of code forking is no longer necessary. You really can just write once and publish everywhere.
I still think DHTML is a useful term, but only in a historical sense. It’s a handy way to refer to the kind of scripts that were written during the browser wars.
DW: Yeah, ECMAScript is a bit of a mouthful.
DW: True. What do you see as the major stumbling blocks to broad adaptation of DOM scripting?
JK: I think that most of the problems are psychological rather than technical. On the one hand, that’s really good: there’s no need to lobby browser vendors or hardware manufacturers to add support for anything—it’s already there. On the other hand, the psychological barriers are very real and, in some cases, quite justified.
But I’m hopeful that people can set aside their trepidation and approach DOM scripting as something that can be rewarding, even fun.
I think the greatest weapon we have when it comes to evangelizing DOM scripting is CSS. Designers have embraced CSS, but writing CSS isn’t like designing something in Photoshop—you really have to think about the structure of the document in order to style it. DOM scripting is just a variation on that—you think about the structure of the document when you want to add behavior.
DW: How about major enticements to adopting it? Or, to put it another way, how do you win over the CSS set?
JK: The simplest and most effective way is to probably point at something that looks and behaves very cool and ask, “Hey, don’t you want to be able to make something like that?”
Maybe there should be a DOM scripting Zen Garden. In the meantime, pointing out nifty bits of well-written DOM scripting (and they’re popping up more and more frequently) should get the ball rolling.
The other big task is to remove the fear. That involves writing clear, jargon-less tutorials that explain just what DOM scripting is and what it can do.
DW: Good point. Are the CSS folks the primary audience for your book? DOM Scripting certainly doesn’t read like a normal scripting primer. Can you talk a little about the decisions you made to differentiate it from other tech books?
JK: Yes, the CSS folks are most definitely the audience I’m aiming for with the book. That’s the major distinguishing factor: it’s a book about a programming language but it isn’t aimed at programmers. I’ve had to walk a very thin line between keeping the explanations simple and being downright patronizing. I hope I didn’t step over that line too often.
I hope that the book will appeal to the CSS-wielding designers who already know the benefits of using standards. I just hope that they don’t get put off by seeing lines of code when they’re leafing through the pages, deciding whether they want to buy it.
DW: How about the traditional DHTML wizards? How do you reach out to them? How do you help people break years of bad habits?
JK: In some ways, that might be a tougher nut to crack. The problem there is convincing people of the benefits of standards. It’s just like trying to explain why nested tables shouldn’t be used for layout: If someone has been using nested tables for years and doesn’t see any benefit to changing their methodology, there’s not much you can do. Likewise, if someone has built up an arsenal of techniques that, on the surface, appear to work (at least in some browsers), they won’t look kindly on the idea of starting afresh.
I think that the marketplace may end up being the deciding factor, as is now happening with CSS. If you make Web sites and you don’t use CSS, you’re a dinosaur and before too long, you’re not going to have much work coming in, but a CSS-savvy designer is going to be increasingly in demand. Eventually, that’s what’s going to happen with old-school DHTML versus the standards-based DOM scripting, although it may take longer.
DW: Agreed. Who do you consider innovators in the DOM scripting world? What/who inspires you?
And of course there are my fellow countrymen and friends, Stuart Langridge and Simon Willison. They have both gone out of their way not just to write cool scripts, but to share some fantastic knowledge with the community at large.
Aaron Boodman, Scott Andrew, Cameron Adams… these guys have been experimenting and consistently coming up with some great results.
And you’re no slacker in the scripting department yourself, Mr. Gustafson.
JK: You have to remember that Ajax != XMLHttpRequest. That’s part of it, but Ajax is first and foremost a methodology.
But as for the XMLHttpRequest object not being a standard, I can totally sympathize with the purists. I’m probably one of them. I hate the thought of using something that doesn’t appear in a specification from the W3C. And, sure enough, the first thing you have to do when you want use Ajax is fork your code: Internet Explorer does it one way, Mozilla another. But, on the whole, sheer pragmatism wins out and the benefits of using the non-standard object win out. I just hope it isn’t a slippery slope that would lead to developers returning to browser-specific code.
But I tend to give people more credit than that. I think that most people want to build cool stuff and do the right thing.
JK: That’s not something we’ve discussed. There are a lot of things we could wind up doing in the future, but for the time being, it’s baby steps. Our first priority is in educating and helping developers. After that, we’ll probably take stock of the situation and see what needs to be done. For now though, we’ve got enough on our plate just dealing with the evangelization and documentation of DOM scripting.
DW: True. Do you think it is something you would be interested in pursuing? How about browser makers? Are you interested in working with them toward improving their products?
JK: Well, the situation now is a lot different than when the WaSP was first formed. In fact, one of the driving factors behind the formation of the WaSP was the lack of support for the standardized DOM. Compared to those dark days, the browser market of today is a DOM scripting paradise. Sure, there are things that could be improved in just about every browser’s support for certain DOM details, but the core functionality exists across the board. It’s a very different situation to the uneven CSS playing field.
That’s something that may come as a pleasant surprise to CSS developers who are making the move to DOM scripting. With CSS, you write your style sheet and then you spend ages trying to get it to work in all the different browsers and operating systems. With DOM scripting, the work all happens at the start. But once you’ve got a function that works in one browser, chances are it’s going to work in nearly all.
Again, that’s not to say that browsers couldn’t be improved in some aspects but, on the whole, cross-browser DOM support is far, far better than CSS support.
DW: What’s next for you? Another book, or are you thinking of taking a break from writing for a while?
JK: I’m definitely not going to be writing another book any time soon—that stuff is hard! But I will be doing lots of writing. I’ll be writing articles for the DOM Scripting Task Force and I also plan to start publishing some stuff on domscripting.com. Writing the book was just the beginning. The real work starts now.
DW: That sounds great. Domscripting.com could turn into a fantastic resource. Final question, and it’s on a bit of a tangent: If Salter Cane takes off and you’re busy touring the world, who would you hire to maintain your Web site?
JK: I’m too much of a control freak to let anyone else touch my site… heck, I don’t even have comments enabled. But if Salter Cane were doing well enough to be touring the road, I would stipulate in my rider that wi-fi must be available in every venue we play. That way, I could fulfill my dreams of rock stardom by night and continue to post irrelevant trivia on my site by day.
DW: Ha, that’s great. Thank you so much for your time.
JK: Thank you Aaron.
Jeremy Keith is a web developer living and working in Brighton, England. He enjoys playing the bouzouki and writing about himself in the third person.