remove attribute vs set to false (v5)

Revision 5 of this benchmark created by Tim Tucker on


Description

For cases in which you want an attribute that works like a flag.

Preparation HTML

<input id="inputSame" type="text" value="The quick brown fox jumps over the lazy dog">
<input id="inputDifferent" type="text" value="The quick brown fox jumps over the lazy dog">
<script>
  var inputEmpty = document.getElementById("inputSame");
  var inputUndefined = document.getElementById("inputDifferent");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
repeatedly set empty
inputEmpty.setAttribute("aria-sort", '');
ready
repeatedly remove undefined
inputUndefined.removeAttribute("aria-sort");
ready

Revisions

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

  • Revision 1: published by Dan Manastireanu on
  • Revision 2: published by Spencer Drager on
  • Revision 3: published by Tim Tucker on
  • Revision 4: published by Tim Tucker on
  • Revision 5: published by Tim Tucker on