show vs addclass (v4)

Revision 4 of this benchmark created by wisevehicle on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style type="text/css">
  .displayClass { display: block; }
</style>
<div id="test" style="display: none;">Hi</div>
<script>
  var elem = document.getElementById("test");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.show()
$(elem).toggle();
ready
.addClass()
$(elem).toggleClass("displayClass");
ready

Revisions

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