useless-toggleClass-x

JavaScript performance comparison

Test case created by Gabriel Schulhof

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="item"></div>
<div class="item"></div>
<div class="item hasclass"></div>
</div>
<script>
window.items = $( ".item" ).remove();
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
1. two useless toggleClass calls
window.items.clone().removeClass( "hasclass" );
pending…
2. no useless toggleClass calls
window.items.clone().toggleClass( "hasclass", false );
pending…

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

Compare results of other browsers

0 comments

Add a comment