getAttribute() vs firstChild.nodeValue

Benchmark created on


Preparation HTML

<p data-a="abc">
  abc
</p>

Test runner

Ready to run.

Testing in
TestOps/sec
getAttribute()
var test1 = document.getElementsByTagName("p")[0].getAttribute("data-a");
ready
firstChild.nodeValue
var test2 = document.getElementsByTagName("p")[0].firstChild.nodeValue;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.