jQuery body vs. document.body selector

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

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

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
$('body')
var body1 = $('body');
pending…
$(document.body)
var body2 = $(document.body);
pending…
plain JS
var body3 = document.body;
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:

3 comments

move database commented :

Simply want to say your article is as surprising. The clarity in your put up is just great and i can assume you are an expert in this subject. Well together with your permission let me to snatch your RSS feed to keep up to date with drawing close post. Thank you one million and please keep up the gratifying work.

watch commented :

Incredible! This blog looks exactly like my old one! It's on a entirely different subject but it has pretty much the same page layout and design. Excellent choice of colors!

sarouel commented :

Great article, totally what I wanted to find.

Add a comment