cssText vs style (v23)

Revision 23 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.

Force a reset and reflow after each test.

Preparation HTML

<div id="element"></div>

Setup

var element = document.getElementById('element');
    var left = 10;
    var top = 50;

Test runner

Ready to run.

Testing in
TestOps/sec
element.style
element.style.left = left + 'px';
element.style.top = top + 'px';
ready
element.cssText
element.style.cssText = 'left:' + left + 'px;top:' + top + 'px';
ready

Revisions

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