jQuery CSS3 Not vs. .Not() vs later removal

JavaScript performance comparison

Revision 34 of this test case created

Info

Tests have shown that css3 not: is faster than the not() method. I want to try if later manipulation of the excluded div isn't faster.

Preparation code

<div id="container">
      <div class="test"> Header </div>
      <div>Div</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Preparation code output

Header
Div

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
CSS3 Selector
var d = $('div:not(.test)').addClass("blue");
pending…
Not() Method
var d = $('div').not('.test').addClass("blue");
pending…
Remove Class later
var d = $('div').addClass("blue");
var e = $('.test').removeClass("blue")
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