jquery css Height vs method Height classes

JavaScript performance comparison

Revision 8 of this test case created by JayP and last updated

Preparation code

<!doctype html>
<html>
 
  <head>
    <meta charset="UTF-8">
    <title>
      無題ドキュメント
    </title>
  </head>
 
  <body>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <div class="test">
    </div>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
    </script>
  </body>

</html>

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
css method _01
$(function() {
  var test = $(".test");
  test.css("height", 500);
})
pending…
css method _02
$(function() {
  var test = $(".test");
  test.css({
    height: 500
  });
})
pending…
height method
$(function() {
  var test = $(".test");
  test.height(500);
})
pending…
mothos 4
$(function(){
var elArr = document.getElementsByClassName('test');
for(var i=0; i<elArr.length; i++) {
 elArr[i].style.height = 500;
}
});
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