style versus jquery css

JavaScript performance comparison

Revision 32 of this test case created by m_gol

Preparation code

<div id="test" style="width: 400px; height: 200px; background-color: #ccc;">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js">
</script>
<script>
var $jq = jQuery.noConflict();
</script>
<script src="//dl.dropboxusercontent.com/u/10200888/jquery/jquery.min.js">
</script>
<script>
var $jqPatched = jQuery.noConflict();
</script>
 
<script>
Benchmark.prototype.setup = function() {
    var testDiv = document.getElementById('test');
    var $jqTest = $jq('#test');
    var $jqPatchedTest = $jqPatched('#test');
};
</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()
$jqTest.css('background-color', '#000000');
pending…
jQuery css() patched
$jqPatchedTest.css('background-color', '#000000');
pending…
Raw style
testDiv.style.backgroundColor = "#000000";
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