inject vs apply

JavaScript performance comparison

Revision 2 of this test case created by Marcos Paulo

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://hostme.co.il/vein.js"></script>
<div id="container"></div>
      
<script>
Benchmark.prototype.setup = function() {
  for(var i=0;i<25;i++){
     $('#container').append($('<h1 class="myHeader">My Header</h1>'));
  }

};

Benchmark.prototype.teardown = function() {
  $('h1', $('#container')).remove();
  vein.inject('h1.myHeader', null);

};
</script>

Preparation code output

<script src="https://hostme.co.il/vein.js"></script> <div id="container"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Application
$('h1.myHeader').css({'color': 'red', 'font-size': '3em'});
pending…
Injection
vein.inject('h1.myHeader', {'color': 'red', 'font-size': '3em'});
pending…

Compare results of other browsers

Revisions

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

0 Comments