For newcomers, is the word "window" confusing?


(Eric Shepherd) #1

I was writing this morning when it occurred to me that we throw the word “window” around a lot, and it has two meanings. New Web developers may not understand that, and we may need to do more to help ensure that confusion doesn’t arise.

The first meaning is the obvious: a window is the user interface construct of a view, usually movable, which may have elements like scroll bars, close boxes, and others in its frame area, with a document or other content within.

The other meaning is the content object represented by the DOM Window interface. Once upon a time, this was the code representation of that same UX apparatus, but it’s not anymore. Window really represents an abstraction that comingles specific attributes of a physical window with those of a browser tab, since a tab is the true parent container of a document nowadays.

The latter explanation is one that we may need to do better at clarifying for new developers. Almost every time we say “window”, we actually mean “tab”, even though a tab is in essence represented by the Window interface.

Any thoughts on (a) how to best describe this concept and (b) how to go about ensuring that new developers understand this? Or is this a non-issue (I don’t think it is, but I could be mistaken).

Eric Shepherd
Senior Technical Writer
MDN Web Docs: https://developer.mozilla.org/
Blog: http://www.bitstampede.com/
Twitter: http://twitter.com/sheppy


#2

Personally, when coding I try to avoid using window entirely. For example, I used to write window.setTimeout() but nowadays I just write setTimeout(), mainly to make the code portable between the browser and Node. The disadvantage is that setTimeout could be overwritten by a local variable, but I can live with that.

There is a TC39 proposal to replace window by global. So once that lands in browsers, we should just be able to replace all usage of window by global, right?

If you are talking about MDN page titles (instead of code), those always use the unwieldy WindowOrWorkerGlobalScope and not Window AFAIK. But even then, I thought those titles must reflect the terms used in the spec, no matter how confusing they are?

Inside text, I agree that “tab” should be preferred over “window”. Alternatively, you could say “page” or “currently open page”, which I’d probably prefer to “tab”.


(Eric Shepherd) #3

The problem is one of accuracy. We don’t want to confuse things, because really, a page is a document, not a window, if you’re going to play with the terminology.

A DOM window is at its core a Window object, which is a container that holds a document, along with the added UX widgetry for moving the container around, opening and closing it, and so forth.

The problem we have here is that that container nowadays actually is a tab, not a window. Closing a DOM Window doesn’t actually necessarily close an operating system level window. It closes the tab in which the document is contained. This is the key difference between the terms Window (with a capital W and presented in a monospace font) and “window” (lower-case “w”). If we say Window, we mean the interface. If we say “window”, we more likely than not mean “tab”, but really we just mean “the thing that contains the document.”

But you don’t necessarily want to use the interface name all the time. You want to be able to casually refer to the thing. We don’t say <input type="checkbox"> everywhere we want to talk about that particular widget. We say “checkbox”.

Eric Shepherd
Senior Technical Writer
MDN Web Docs: https://developer.mozilla.org/
Blog: http://www.bitstampede.com/
Twitter: http://twitter.com/sheppy
I guess the point is that we might consider making sure we clarify in the early bits of the learning area and in the appropriate bits of the DOM reference this little terminology quirk left over from prehistoric times when browsers only had one document per window. :slight_smile:


#4

Ah, I understand now. document = page, window = tab.

I don’t have a strong opinion on either side. My gut feeling is to keep using window because that’s the term used e.g. by the window object, so any newcomer will stumble across it eventually. An experienced developer would most likely be confused when reading tab.

On pages that specifically deal with the current “window”, e.g. window.close(), it makes sense to talk about tabs instead of windows, I agree.


(Eric Shepherd) #5

I figure that if we at least introduce the true meaning of “window” in the context of Web documentation, new readers will pick it up quickly enough. We certainly don’t need to systematically change every page that talks about windows. :slight_smile:

Eric Shepherd
Senior Technical Writer
MDN Web Docs: https://developer.mozilla.org/
Blog: http://www.bitstampede.com/
Twitter: http://twitter.com/sheppy