jQuery CSS vs addClass speed (v10)

Revision 10 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<style type="text/css">
.newClass {
height: 100%;
}
</style>

<div class="some preexisting classes"></div>

Teardown


    $('div').remove();
    $('body').append('<div class="some preexisting classes"></div>');
    
  

Test runner

Ready to run.

Testing in
TestOps/sec
Add class
$('div').addClass('newClass');
ready
Apply CSS
$('div').css({'height':'100%'});
ready

Revisions

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