4 ms·
Hands down there is one objective thing that Firefox does well and nobody else comes remotely close. DOM access. For some reason Firefox is thousands of times
by austincheney 8y ago
Hands down there is one objective thing that Firefox does well and nobody else comes remotely close. DOM access. For some reason Firefox is thousands of times faster than other browsers when it comes to executing the standard DOM API methods.
I know that is a bold statement but it is easily verified with numbers using a perf tool. Chrome is faster at executing JavaScript than Firefox, but even still Firefox leaves everybody completely in the dust when executing the DOM API.
DOM access is so incredibly important to how the web works and nobody really talks about. For some unknown reason most developers are deathly afraid of the DOM and will do everything possible to hide from it. It is common in every job I have worked to see mountains of querySelectors and 10mb of supporting framework code so that developers don't have to fear the DOM buggy man. I could sympathize if the DOM were complicated, but it isn't.
I really believe if Firefox goes away and that competition is gone the web will get fundamentally slower. Everybody will see this slowness and yet very few people be able to diagnose why, and that is tragic.
- Waterluvian 8y agoMy understanding is that DOM manipulation and queries will always be far far slower than the logical equivalent in JavaScript. Does "thousands of times faster" challenge that? Ie. React's virtual DOM is a phenomenal idea because it greatly reduces actual DOM interaction. Is it not really saving us much in Firefox?
- austincheney 8y agoThe 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.
- bzbarsky 8y ago> DOM manipulation and queries will always be far far slower than the logical equivalent in JavaScript. That really depends on what you're doing. Reimplementing querySelector in JavaScript (even if you do it on top of JS-only node representations, not on actual nodes) is likely to be slower than the built-in version, for example. If you're doing a "modify-read-modify-read" cycle, then things are different because the contract is different: the DOM promises that reads will see all modifications, while some of the other systems built around it don't. > Is it not really saving us much in Firefox? It really depends on the shape of your workload. There are various cases where React's virtual DOM is pure overhead and just makes things slower. [Disclaimer: I work on a browser rendering engine, and have done a fair amount of performance work, so I may have my biases about what I see in profiles.]