append vs find

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    $('body').append('<div id="testing"></div>')
};

Benchmark.prototype.teardown = function() {
    $('#testing').remove()
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
find
window.body = $('#testing');
window.tmp = $('<div class="cntr"></div><div class="test"></div>');
body.append(tmp);
window.cntr = body.find('.cntr');
window.test = body.find('.test');
pending…
append
window.body = $('#testing');
window.cntr = $('<div class="cntr"></div>');
window.test = $('<div class="test"></div>');
body.append(cntr);
body.append(test);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment