fastest hasClass functions

Benchmark created by bbarr on


Description

This will test all of the major HTML class attribute utility functions.

Please contribute with other solutions!

Preparation HTML

// test elements
<div id="single-class" class="a"></div>
<div id="multiple-classes" class="a b abcd a-b-c-d"></div>

// libraries to test
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//github.com/dgalarza/RaptorJS/raw/master/src/raptor.pack.js"></script>
<script>
  // RaptorJS
  var $p = raptor.pack; // to keep prop look-ups equal with competition
  var single_class = document.getElementById('single-class');
  var multiple_classes = document.getElementById('multiple-classes');
  
  // jQuery
  var jQuery_single_class = $('#single-class');
  var jQuery_multiple_classes = $('#multiple-classes');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
RaptorJS hasClass
$p.hasClass('a', single_class);
$p.hasClass('a', multiple_classes);
ready
jQuery hasClass
jQuery_single_class.hasClass('a');
jQuery_multiple_classes.hasClass('a');
ready

Revisions

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

  • Revision 1: published by bbarr on
  • Revision 2: published by dgalarza on
  • Revision 3: published by Bruno Garcia on
  • Revision 4: published by Bruno Garcia on
  • Revision 10: published on