Kimbo vs jQuery closest method

JavaScript performance comparison

Revision 2 of this test case created by Denis

Preparation code

<script src="http://kimbojs.com/lib/kimbo.js">
</script>
<script src="http://kimbojs.com/lib/jquery.js">
</script>
<script src="http://zeptojs.com/zepto.min.js">
</script>
<div id="main">
  <div id="container">
    <div class="article">
      <ul class="article_menu">
        <li>
          Item 1
        </li>
      </ul>
      <div class="article">
        <p id="p">
          Actual article that shares article class styles.
        </p>
      </div>
    </div>
  </div>
</div>
<script>
  window.$k = Kimbo;
  window.$j = jQuery;
  window.$z = Zepto;
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var $kp = $k('#p');
  var $jp = $j('#p');
  var $zp = $z('#p');

};
</script>

Preparation code output

<script src="http://kimbojs.com/lib/jquery.js"> </script> <script src="http://zeptojs.com/zepto.min.js"> </script> <div id="main"> <div id="container"> <div class="article"> <ul class="article_menu"> <li> Item 1 </li> </ul> <div class="article"> <p id="p"> Actual article that shares article class styles. </p> </div> </div> </div> </div> <script> window.$k = Kimbo; window.$j = jQuery; window.$z = Zepto; </script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Kimbo closest
$kp.closest('.article');
pending…
jQuery closest
$jp.closest('.article');
pending…
Zepto closest
$zp.closest('.article');
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.

1 Comment

Denis (revision owner) commented :

In this test there is a limitation and is that Zepto doesn't support getting multiple closest elements from a set, so here is being tested only 1 element to be returned from the closest function.

Suppose this html structure:

paragraph 1

paragraph 2

If we wan't to get the closest div for all paragraph, with Kimbo or jQuery:

$('p').closest('div');

Will return [div.p_closest_1, div.p_closest_2]

but Zepto will return only the first one [div.p_closest_1]

  • Item 1

Actual article that shares article class styles.