ChapterÂ 3.Â DOM Scripting
DOM scripting is expensive, and itâs a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an applicationâs responsiveness and gives recommendations on how to improve response time. The three categories of problems discussed in the chapter include:
Accessing and modifying DOM elements
Modifying the styles of DOM elements and causing repaints and reflows
Handling user interaction through DOM events
But firstâwhat is DOM and why is it slow?
DOM in the Browser World
The Document Object Model (DOM) is a language-independent application interface (API) for working with XML and HTML documents. In the browser, you mostly work with HTML documents, although itâs not uncommon for web applications to retrieve XML documents and use the DOM APIs to access data from those documents.