a brief comparison of selection methods
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul>
<li>
<div class="thumb">
<img src="image-1.jpg">
</div>
</li>
<li>
<div class="thumb">
<img src="image-2.jpg">
</div>
</li>
<li>
<div class="thumb selected">
<img src="image-3.jpg">
</div>
</li>
</ul>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
$("div.selected img").attr("src") |
|
pending… |
$('img').filter(return $(this).closest('div.selected').length;).attr('src'); |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments