Native Browser events vs jquery trigger

JavaScript performance comparison

Revision 6 of this test case created by JP Grace

Preparation code

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

      
<script>
Benchmark.prototype.setup = function() {
  window.$el = jQuery("<div id='test'></div>").appendTo(document.body);
  window.el = document.getElementById('test');

};

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

};
</script>

Preparation code output

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

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
// async test
window.$el.one("click", function() {
  setTimeout(function() {
    deferred.resolve();
  }, 10);
});

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