Jquery .css() vs JS.style

JavaScript performance comparison

Revision 8 of this test case created by Nicholas A


Changes the background of div#test to black. Note: Uses the latest jQuery 1.6.

Preparation code

<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.min.js"></script>
<div id="test" style="height:100px;width:100px;position:absolute;top:-100px;left:-200px;"></div>

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
$("#test").css('backgroundColor', '#000');
var myelem = document.getElementById("test");
myelem.style.backgroundColor = "#000";

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:

1 comment

Nicholas A (revision owner) commented :

I don't understand what's wrong with my test. I keep getting a some error about "$" (jQuery) not being defined.

Add a comment