setTimeout is not part of the DOM #72

simevidas opened this Issue Apr 8, 2011 · 13 comments


None yet
5 participants

The side-note in the chapter about setTimeout is not correct. Quote: "Note: Timeouts are not part of the ECMAScript Standard. They are implemented as part of the DOM."

The setTimeout function and the DOM are not related. The setTimeout function is a global function in the browsers. The DOM is rooted in the document object. Therefore, the timer functions are not part of the DOM in any way.

The note should read: "They are implemented in browsers as global functions (properties of the widow object)."


oozcitak commented Apr 8, 2011

The root of the DOM is not the document object, it is the window object. document is actually a property of the window object. (along with other properties such as location, history, etc.)

I disagree. Do you have a source? If you do, please give it.

The DOM specs (the W3C DOM standards) do not mention the window object. The topmost entity defined by the DOM specs is the Document interface. In the browsers, this interface is implemented by the document object. Therefore, the document object is the root of the DOM in the browser.

The browsers implement lots of other global properties (besides the document object). For instance: location, history, navigator, applicationCache, localStorage and sessionStorage, console, the timer functions, alert, postMessage, getSelection, etc. All those properties are NOT considered as part of the DOM.

simevidas closed this Apr 8, 2011

I accidentally closed this issue (I'm new to Github). Please re-open.

ZhangYiJiang reopened this Apr 8, 2011


oozcitak commented Apr 8, 2011

After reading the specs once more, I concur. I always assumed the window object was at the top of the DOM hierarchy (think event bubbling), but it appears that it is just part of an optional interface.


ZhangYiJiang commented Sep 25, 2011

For what its worth, MDN claims window.setTImeout is part of DOM Level 0. I've also heard of it classified under the Browser Object Model, whatever that is (this SO question does nothing to clear it up).

I've added my answer to that SO question.


timruffles commented Oct 9, 2013

It's not part of Javascript the language - it's part of the Javascript environment in the browser (& node). But you're right it's not part of the DOM standard either.

If you fancy updating the wording to be more specific that'd be great! Otherwise I'll close in a few days.

timruffles closed this Apr 30, 2014


kiding commented Jul 24, 2014

Even to this day, I think the sentence is misleading. "They are being standardized in HTML5" maybe?

Since it's not in ECMAScript standard, node.js has its own implementation; it doesn't return a number ID from setTimeout/setInterval but rather an object. HTML5 states setTimeout should accept parameters that can be delivered to the given function, but IE currently implements it differently, although this difference is not mentioned in the article.

So I think my proposal does imply that they might not work reliably on some JavaScript platforms, also that they might work differently depending on browsers. What do you think?


timruffles commented Jul 24, 2014

Pull requests definitely accepted - with some context. Perhaps as a footnote?


kiding commented Jul 24, 2014

I'm not sure how to write a footnote since I can't find any example in the article. If we were to write also the context in the Note: section we're talking about, it might be a bit long. Will that be okay? 5 lines tops, I guess.


kiding commented Jul 26, 2014

So I've made a pull request referencing this issue. Any comment is appreciated. Thanks!


timruffles commented Jul 28, 2014

great - merged it! thanks


kiding commented Jul 28, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment