Native Browser events vs jquery trigger

JavaScript performance comparison

Revision 13 of this test case created by prasanth

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://johnkpaul.github.com/jquery-simulate/jquery.simulate.js">
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var $el = jQuery("<div id='test'></div>").appendTo("body");
  var el = $el.get(0);
  
  var events = [];
  $el.on("doom", function(e) {
    events.push(e);
  });

};

Benchmark.prototype.teardown = function() {
  $el.remove();

};
</script>

Preparation code output

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
jQuery trigger
$el.trigger("doom");
pending…
jQuery triggerHandlers
$el.triggerHandler("doom");
pending…
native event
var event = new Event('doom');
el.dispatchEvent(event);
pending…
native event through simulate plugin
$el.simulate("doom");
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