jQuery hide() and show() vs. addClass() and removeClass()

Benchmark created on


Preparation HTML

<style>.hidden{display:none;}</style>
<div class="element">element</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var $element = $('.element');
    var hideClass = 'hidden';

Test runner

Ready to run.

Testing in
TestOps/sec
hide() and show()
$element.hide();
$element.show();
ready
addClass() and removeClass()
$element.addClass(hideClass);
$element.removeClass(hideClass);
ready

Revisions

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