dom query vs js tracking
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var html = '';
for(var i = 1000; i> 0; i--){
if( i === 14 || i === 16) {
html += '<div class="foo blue'+i+'"></div>';
} else {
html += '<div class="foo"></div>';
}
}
$('body').append(html);
var $el = $('.foo.blue14');
</script>
<style>
.foo {
background:#fcc;
height: 10px;
margin-top: 4px;
}
.blue14, .blue16 {
background: blue;
}
</style>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
dom query |
|
pending… |
test |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments