jQuery body vs. document.body selector

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

<script src="https://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
var body1 = $('body');
var body2 = $(document.body);
plain JS
var body3 = document.body;

Compare results of other browsers


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:


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.

Comment form temporarily disabled.

Add a comment