jQuery css styling

JavaScript performance comparison

Test case created by Brian Cerceo

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
  <li>hello</li>
</ul>
<script>
Benchmark.prototype.setup = function() {
    var $li = $('ul').find('li');
};
</script>

Preparation code output

  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello
  • hello

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
css parameter (short hex)
$li.css('color','#FFF');
pending…
css parameter (full hex)
$li.css('color','#FFFFFF');
pending…
css map (short hex)
$li.css({ color: '#FFF' });
pending…
css map (full hex)
$li.css({ color: '#FFFFFF' });
pending…
css map multiple properties
$li.css({ 'color': '#FFFFFF', 'border-color': '#FFFFFF', 'font-size': 12, 'padding': 5, 'margin': 5 });
pending…
css parameter multiple properties
$li.css('color','#FFFFFF').css('border-color','#FFFFFF').css('font-size',12).css('padding',5).css('margin',5)
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