cssText vs style (v12)

Revision 12 of this benchmark created on


Description

Comparing the performance of using style against changing directly cssText. Also compared against with just adding a css classname.

Preparation HTML

<div id="element">
</div>
<style type=”text/css”>
  .newClass { left: 10px; top:50px; }
</style>

Test runner

Ready to run.

Testing in
TestOps/sec
element.style
var element = document.getElementById('element');
element.style.left = '10px';
element.style.top = '50px';
ready
element.cssText
var element = document.getElementById('element');
element.style.cssText = 'left:10px;top:50px;';
ready
change css class
var element = document.getElementById('element');
element.className = 'newClass';
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.