tezvyn:

Browser Object Model: The Browser's Unruly API

AI-drafted, machine-checkedSource: Wikipedia: Browser Object Modelintermediate

The Browser Object Model (BOM) is the collection of non-standard APIs browsers expose for interacting with the browser window. Unlike the standardized DOM, its implementation is up to each vendor, creating a major cross-browser compatibility footgun.

WHY IT EXISTS: Web pages need a way to interact with the browser environment that contains them, not just the document content. The Browser Object Model provides the objects for this interaction, as defined by each browser vendor.

THE MENTAL MODEL: The Browser Object Model (BOM) is a convention, not a formal standard, that refers to all the objects exposed by a web browser. It is entirely separate from the Document Object Model (DOM), which handles the page content. Think of the DOM as the standardized API for the document and the BOM as the proprietary API for the browser containing it.

HOW IT WORKS: There is no single way the BOM works because it lacks a standard for implementation and has no strict definition. Browser vendors are free to implement the BOM in any way they wish. This means the objects available and their behavior can differ significantly between browsers like Chrome, Firefox, and Safari.

WHEN TO USE IT: Use the BOM when you need to interface with browser-specific features not covered by the standardized DOM, such as interacting with the browser window, history, or location.

WHEN NOT TO USE IT: Avoid relying on the BOM for critical functionality if you require consistent behavior across all major browsers. Its non-standard nature makes it inherently unreliable for cross-browser code. Always check for feature existence before using a BOM API.

ONE CANONICAL EXAMPLE: The core concept is that the BOM represents the entire collection of browser-exposed objects that are not part of the DOM. Unlike the DOM's document.getElementById(), which is standardized, a BOM feature might exist in one browser but not another. For example, interacting with browser history or screen information falls under the BOM.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.