jQuery attr vs Vanilla JS - revised
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul>
<li id="item1">
Item 1 with id attribute
</li>
<li id="item2">
Item 2 with id attribute
</li>
<li id="item3">
Item 3 with id attribute
</li>
</ul>
Preparation code output
- Item 1 with id attribute
- Item 2 with id attribute
- Item 3 with id attribute
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Get id attribute using jQuery |
|
pending… |
Get id attribute using Vanilla JS |
|
pending… |
Get id from jQuery DOM element |
|
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
- Revision 2: published
0 comments