Browser Diet - $(this).attr('id') vs. this.id
JavaScript performance comparison
Preparation code
<a id="a" class="tests" href="#">a</a>
<a id="b" class="tests" href="#">b</a>
<a id="c" class="tests" href="#">c</a>
<a id="d" class="tests" href="#">e</a>
<a id="f" class="tests" href="#">f</a>
<a id="g" class="tests" href="#">g</a>
<a id="h" class="tests" href="#">h</a>
<a id="i" class="tests" href="#">i</a>
<a id="j" class="tests" href="#">j</a>
<a id="k" class="tests" href="#">k</a>
<a id="l" class="tests" href="#">l</a>
<a id="m" class="tests" href="#">m</a>
<a id="n" class="tests" href="#">n</a>
<a id="o" class="tests" href="#">o</a>
<a id="p" class="tests" href="#">p</a>
<a id="q" class="tests" href="#">q</a>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$testList = $('.tests');
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
jQuery's .attr() |
|
pending… |
Pure JavaScript |
|
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:
- Revision 1: published by Zeno Rocha
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published by Kowsalya
- Revision 6: published
- Revision 7: published by Casey Flynn
- Revision 8: published by Casey Flynn
- Revision 9: published by Casey Flynn
- Revision 10: published
0 comments