2 ms·
The DOM is a structured API to markup (HTML/XML). That means DOM instructions are access to something outside the language. Leaving the language, for any reas
by austincheney 8y ago
The DOM is a structured API to markup (HTML/XML). That means DOM instructions are access to something outside the language. Leaving the language, for any reason, is slower than executing within the language. That said the execution speed of DOM instructions is orthogonal to the execution speed of JavaScript alone.
> Is it not really saving us much in Firefox?
The DOM is the standard technology the browsers use to communicate from JavaScript to markup. QuerySelectors are strings, so they have to be parsed into DOM instructions by the browser using a native code engine. Since the DOM is a well defined standard and it is the standard that all browsers use DOM instruction performance can be directly compared between the different browsers.