change css in many ways

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

<script src=""></script>
<div id="id"></div>
Benchmark.prototype.setup = function() {
    var left = 10,
      top = 10,
      el = document.getElementById('id'),
    this.c = $(el).css;

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
style.x = left + "px";  = top  + "px";
cached style.x
styl =;

styl.left = left + "px"; = top + "px";
cssText += "; left: " + left + "px; top: " + top + "px;";
  left: left,
  top: top
shortcut to $ function
this.c('left', left);
this.c('top', top);

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

James commented :

Anyone had a look at how it's implemented within jQuery? it's only more JS not magic... I will have a look but bit busy with work.

Comment form temporarily disabled.

Add a comment