jQuery chaining (v3)

Revision 3 of this benchmark created on


Description

Tests whether chaining jQuery function calls is noticeably faster than separate calls.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="theDiv">Some text</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Chained
$('#theDiv').addClass('test').addClass('test2').removeClass('test2').removeClass('test');
ready
Separate calls
$('#theDiv').addClass('test');
$('#theDiv').addClass('test2');
$('#theDiv').removeClass('test2');
$('#theDiv').removeClass('test');
ready
Separate calls (cached)
var d = $('#theDiv');
d.addClass('test');
d.addClass('test2');
d.removeClass('test2');
d.removeClass('test');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.