jQuery CSS3 Not vs. .Not()

JavaScript performance comparison

Revision 36 of this test case created by npjohns

Info

Not the best test design, but this must be the situation jquery docs were referring to with :not being slower. Only makes sense if you plan on reusing the first $('div') results.

Preparation code

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

Preparation code output

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
$('div').filter(':not(#header)');
pending…
Not() Method
$('div').not('#header');
pending…
reuse Not()
var d = $('div');
d.not('#header');
d.not('#footer');
pending…
CSS3 instead of reuse
var d = $('div');
$('div:not(#header)');
$('div:not(#footer)');
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