Douglas Crockford




2024 Appearances






Electric Communities


Flickr Photo Album



Pronouns: pe/per


DOM Is As DOM Does

I started writing JavaScript in 2000. Our first two applications were social: a trading collecting game and a graphical chat system. I had previously invested tens of millions of dollars in Java projects, and was very disappointed in the results. So in a fit of desperation, I decided to give the browser a try.

The number of browsers at that time was either 2 or n, depending on how you did your reckoning. There was Netscape Navigator and Microsoft Internet Explorer. There were others, like Mosaic and Lynx, but they did not run JavaScript, and their marketshare was insignificant. NN was up to its 4th edition. IE was up to 5.5. There was no sort of auto-update yet, so the majority of users tended to stay on the first version they installed. Macintosh versions were quite different from Windows versions. Making things worse, there were frequent bug fixes released, which sometimes introduced new bugs. You could not depend on fixes getting installed, which meant that the number of testable browsers was huge and constantly growing, approaching n. The set of potential browsers bugs only grew.

The API that the browser presented to JavaScript was the strangely named Document Object Model, or DOM. It was at its core a badly designed model which Netscape and Microsoft interpreted and extended in incompatible ways. It was a difficult time to be a web developer, which is why we saw virtually no successful web development (as we currently understand it) until the Ajax Revolution of 2005.

Two important things happened to make the Ajax Revolution possible. The first was that Netscape failed to deliver Navigator 5. They did deliver Navigator 6 and 7, but they were so unstable that they failed to get much adoptions. So use of Netscape Navigator slowly declined as old computers that had it installed failed or were replaced. The second was that Microsoft disbanded the Internet Explorer team thinking that the Browser War was over. They put IE6 into maintenance, and put all of their creative energy into Dot Net, WPF, and the failure that would become Silverlight.

The consequence of this neglect of the web was that IE6, which was the best web browser the world had ever seen*, took an enormous share of the market. Now a web developer had only one version to support. The huge catalog of bugs and incompatibilities shrank down to just the final IE6 bugs, which was an infinitely smaller bugset than we faced in 2000. The web had become stable enough that we could now profitable write for it. Ajax was not a new idea. I was doing it in 2000. There were other arrowbacks who were doing it as early as 1996.

Things were better, but the DOM had not been fixed. I recommended avoiding the DOM, accessing it indirectly through popular libraries. The libraries could hide much of the horror that is the DOM. There were many of these libraries, including a few that I had written myself. They all provided a more pleasant and productive experience. The most difficult part about adopting an Ajax library was selecting the right one.

But for my last few projects, I have gone back to writing directly to the DOM. Those libraries have all grown into grotesque frameworks with complex tool chains that were optimized for coders who do not want to ever learn to use JavaScript well. They create monstrous bloat, causing performance problems and other complexities. So I am now using the plain old DOM, and it is not nearly as awful as I remember.

That is because the web standards movement tormented Microsoft and other browser makers to improve the quality of their browsers. WHATWG, frustrated with the inaction of W3C, started drafting its own standard. While I disagreed with much of it, there was no doubt that it was better thought out than what W3C had been publishing.

So I have changed my mind about the DOM. It is still awful, but it is much better than the popular alternatives.

*Yes, it is hard to imagine that IE6 was the best browser that the WWW had ever seen. That is just how bad the WWW was in 2000.