Dom is a language-independent API, its browser in the pretext is to use JS to achieve.
Browsers usually implement the DOM and JS independently.
In IE, the implementation name of JS is JScript, located in the Jscript.dll file, the DOM implementation is Mshtml.dll;
The DOM and rendering in Safari are implemented using the WebCore in WebKit, and JS is implemented with an independent javascriptcore engine;
Google Browser, also use WebKit in the WebCore to render the page, but the JS engine is implemented by V8;
The JS engine in Firefox is named SpiderMonkey (the latest version of the name is Tracemonkey) and is independent of the rendering engine named Gecko.
Browser |
JS Implementation engine |
DOM Implementation engine |
Ie |
JScript (in a Jscript.dll file) |
Mshtml.dll |
Safari |
The WebCore in WebKit |
JavaScriptCore |
Chrome |
The WebCore in WebKit |
V8 |
Firefox |
SpiderMonkey (the latest version is Tracemonkey) |
Gecko |
Two separate functions are consumed as long as they are connected to each other via an interface. Access to the DOM also generates a certain amount of consumption.
Access and modification of the DOM
There is a cost to accessing the DOM element----as the book says about the bridge fee, modifying the element is more expensive, because he causes the browser to recalculate the geometric changes of the page . Of course, the worst-case scenario is accessing or modifying elements in a loop, especially the looping operation of the collection of HTML elements.
As the above code: the problem with this code is that the-----Each loop, the element will be accessed two times, one time to read the innerHTML property value, and another rewrite it;
More efficient way to store modified content with local variables and write once at the end of the loop:
Read JS High performance summary--dom programming (i)