show vs addclass

Benchmark created by Nick Craver 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).show();
ready
.addClass()
$(elem).addClass("displayClass");
ready

Revisions

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