jQuery CSS vs addClass speed (v16)

Revision 16 of this benchmark created on


Preparation HTML

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

<style type="text/css">
.newClass {
background-color:red;
}

.otherClass {
background-color: green;
}
</style>

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

Teardown


    $('div').css({'background-color':'red'});
    
  

Test runner

Ready to run.

Testing in
TestOps/sec
Add Class
$('div').addClass('newClass');
ready
Add CSS
$('div').css({'background-color':'red'});
ready

Revisions

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