Native Browser events vs jquery trigger

JavaScript performance comparison

Revision 14 of this test case created by

Preparation code

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

};

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

};
</script>

Preparation code output

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

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("click");
pending…
var mouseEvent = document.createEvent("MouseEvents");
mouseEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(mouseEvent);
pending…
native event
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