Document Object Model
The DOM represents a document as objects and nodes with interfaces that programs can inspect and modify.
Not independently verified. References are provided for review; their presence does not certify every claim.
Document Object Model
The DOM represents a document as objects and nodes with interfaces that programs can inspect and modify.
Document, tree and display
HTML source is parsed into a document tree. Elements, text and other nodes become accessible through APIs. The DOM is not the same thing as the original source text or the pixels on screen: scripts can change nodes, and style/layout/painting determine their visual presentation.
JavaScript commonly uses the DOM, but the DOM is an API model rather than part of the JavaScript language.
Safe content insertion
const paragraph = document.createElement("p");
paragraph.textContent = "A user-supplied title";
document.querySelector("main").append(paragraph);
Using textContent treats the value as text. Interpreting untrusted strings as HTML can introduce script injection; input validation · not yet documented alone does not replace correct output handling.
Events and performance
Event listeners respond to user or programmatic events. Dispatch can invoke several listeners according to event propagation rules. Frequent interleaved layout reads and writes may force expensive rendering work.
Workers cannot directly edit the page DOM. They can calculate a result and send it to the page, which applies an update.
Practice
Create a list, append items with element APIs and handle clicks with one listener on its container. Use a debugger to inspect the clicked node and propagation. Assessment: explain why a DOM mutation does not mean the browser has already painted a frame. Continue with the event loop and Web Workers.
References and verification
These sources are provided for claim review. This article is Needs review; no verification date is asserted. Original research ranges, where available, are retained in the catalog.
- Introduction to the DOM — MDN Web Docs.
References & provenance
MDN Web Docs · Official documentation · Needs review · Access date not recorded
- The DOM as a document API
Original research context, including questions and later corrections:
Research lines 4801–4965My learning
Your learning
Saved in this browser. Status and proficiency are independent.
Loading your saved workspace…