Get Attribute value

JavaScript performance comparison

Revision 3 of this test case created

Info

Getting the attribute value when the element object is already known.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<input id="test" name="test" />
<script>
  var test = document.getElementById('test');
  var testJquery = $(test);
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Using jQuery
var name = $(test).attr('name');
pending…
JavaScript
var name = test.name;
pending…
Using Cached Jquery Element
var name = testJquery.attr('name');
pending…
jquery selector + javascript
var name = testJquery.name;
pending…
test.getAttribute('name');
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:

0 comments

Add a comment