jquery css or csstext

JavaScript performance comparison

Revision 2 of this test case created by Magnus

Preparation code

<div id="styleme">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var $elem = $('#styleme');
};
</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
$elem.css({
  position: 'fixed',
  height: 1600,
  width: 1600,
  top: 0,
  'overflow': 'hidden'
});
pending…
csstext
$elem[0].style.cssText += ';'.concat('position:fixed;', 'height:1600px;', 'width:1600px;', 'top:0;', 'overflow:hidden;');
pending…
$elem.css('cssText', 'position:fixed; height: 1600; width: 1600 !important; top: 0; overflow:hidden');
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