Document.body vs document.getElementsByTagName('body')[0] (v3)

Revision 3 of this benchmark created by Dennis on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
document.body
var body = document.body;
ready
document.getElementsByTagName('body')[0]
var body2 = document.getElementsByTagName('body')[0];
ready
$('body')
var body3 = $('body');
ready
$(document.body)
var body4 = $(document.body);
ready

Revisions

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