Each web browser has two separate engines, one for the implementation of JavaScript and one for the DOM. When you call a JavaScript function, you're using the JavaScript engine, while when you call a DOM method, you're using the DOM engine. Traditionally the DOM engine has always been slower than its JavaScript counterpart, so browser vendors put much effort in optimizing the performance of this engine. A particular case is Chrome, which clearly shows how the optimization of the DOM engine can be actually pushed to the limits. This video explains the details of such optimization.