style versus jquery css

JavaScript performance comparison

Revision 28 of this test case created

Preparation code

<div id="test" style="width: 400px; height: 200px; background-color: #ccc;">
</div>
<script src="//code.jquery.com/jquery-git2.js"></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
Jquery css()
$('body').css('background-color', '#101010');
pending…
Raw style
document.getElementsByTagName('body')[0].style.backgroundColor = "#101010";
pending…
jQuery CSS multiple
$('body').css({
    'background-color': '#101010'
});
pending…
Raw style
document.body.style.backgroundColor = "#101010";
pending…
Hybrid
$('body')[0].style.backgroundColor = "#101010";
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