jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
I want to compare performance on dom Queries between dojo queries, jQuery selectors and native implementations.
This is the third of several tests. I'm going to select a set of classes and add a class to each, then filter go to the parent of each and set an inline style on it.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js"></script>
require(['dojo/query', 'dojo/dom', "dojo/NodeList-traverse"], function(query, dom) {
dQuery = query;
dDom = dom;
});
//Native code to define once
function addClass(node, className) {
if (!node.length) node = [node];
for (var n = 0, m = node.length; n < m; n++) {
if ((" " + node[n].className + " ").indexOf(" " + className + " ") >= 0) {
node.className += " " + className;
}
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery class manipulation |
| ready |
Dojo class manipulation |
| ready |
Native class manipulation (IE9 Compatible) |
| ready |
Native class manipulation (Non-IE9 compatible) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.