directvs

Benchmark created by Jakub on


Preparation HTML

<div id='a' style="height: 100px; width:100px">

</div>
<script>
  var elm = document.getElementById('a');
  var elmstyle = elm.style;
  var clone = elm.cloneNode(true);
  var clonestyle = clone.style;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
direct
document.getElementById('a').style.backgroundColor = 'green';
document.getElementById('a').style.opacity = 0.9;
ready
var
elm.style.backgroundColor = 'yellow';
elm.style.opacity = 0.9;
ready
style
elmstyle.backgroundColor = 'red';
elmstyle.opacity = 0.9;
ready
clone
clone.style.backgroundColor = 'blue';
clone.style.opacity = 0.9;

elm.parentNode.replaceChild(clone,elm);
ready
clonestyle.backgroundColor = 'grey';
clonestyle.opacity = 0.9;
ready

Revisions

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