Remove style

Benchmark created by Premasagar Rose on


Description

When manipulating CSS styles on DOM elements, which is faster? Setting the property to a blank string or using the CSS DOM removeProperty() method?

Preparation HTML

<script>
  var elem = document.createElement("span"),
      elemStyle = elem.style;
  
  document.body.appendChild(elem);
  elem.innerHTML = "this is a test";
  elemStyle.color = "red";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
blank string
elemStyle.color = "blue";
elemStyle.color = "";
ready
removeProperty
elemStyle.color = "blue";
elemStyle.removeProperty("color");
ready

Revisions

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

  • Revision 1: published by Premasagar Rose on