jQuery CSS3 Not vs. .Not() (v25)

Revision 25 of this benchmark created by jD on


Preparation HTML

<div id="container">
  <div id="header" class="header">
    Header
  </div>
  <div>
    Div
  </div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
var rClassTest = /\bheader\b/;
</script>

Setup

var class_test = rClassTest;

Test runner

Ready to run.

Testing in
TestOps/sec
CSS3 Selector -- id
var d = $('div:not(#header)');
ready
CSS3 Selector -- class
var d = $('div:not(.header)');
ready
Not() Method -- id
var d = $('div').not('#header');
ready
Not() Method -- class
var d = $('div').not('.header');
ready
Filter by pure js -- id
var d = $('div').filter(function() {
  return this.id !== 'header';
});
ready
Filter by pure js -- class
var d = $('div').filter(function() {
  return class_test.test(this.className);
});
ready
Filter by pure js, cache function -- id
var func = function(b) {
  return b.id !== 'header';
}
var d = $('div').filter(func(this));
ready
Filter by pure js, cache function -- class
var func = function(b) {
  return class_test.test(b.className);
}
var d = $('div').filter(func(this));
ready

Revisions

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