jQuery CSS3 Not vs. .Not()

JavaScript performance comparison

Revision 21 of this test case created

Info

The jQuery docs specify that it's better to use .not() over $('x:not(y)'). Testing to make sure that's the case in all browsers.

Preparation code

<div id="container">
  <div id="header">
    Header
  </div>
  <div>
    Div
  </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
var d = $('div:not(#header)');
pending…
Not() Method
var d = $('div').not('#header');
pending…
Filter Method
var d = $('div').filter(function() {
  return $(this).attr('id') !== 'header';
});
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