Native Browser events vs jquery trigger
JavaScript performance comparison
Info
Comparison between three different methods of triggering events for use in unit testing.
- jQuery's trigger
- Native browser events using document.createEvent
- Native browser events using jQuery's simulate plugin
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//johnkpaul.github.com/jquery-simulate/jquery.simulate.js">
</script>
<script>
Benchmark.prototype.setup = function() {
window.$el = jQuery("<div id='test'></div>").appendTo(document.body);
};
Benchmark.prototype.teardown = function() {
window.$el.remove();
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
jQuery trigger |
|
pending… |
native event |
|
pending… |
native event through simulate plugin |
|
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. Here’s a list of current revisions for this page:
- Revision 1: published by John K Paul
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
0 comments