jqueryAddClass

JavaScript performance comparison

Test case created

Info

proto against jquery

Preparation code

<div id="asdf"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" >Element.prototype.addClass = function ( cName ){
  var classNames = this.className.split( ' ' );
  //if class doesn't allready exist
  if( classNames.indexOf( cName ) == -1 ){
    classNames.push( cName );
    this.className = classNames.join( ' ' );
  }
}</script>
<script type="text/javascript" >
var $asdf = $( "#asdf" );
var asdf = document.getElementById( 'asdf' );
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jquery
$asdf.addClass( 'wouter' )
pending…
proto
asdf.addClass( 'wouter' )
pending…

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

Compare results of other browsers

0 comments

Add a comment