jQuery Event this (v2)

Revision 2 of this benchmark created by Rick Waldron on


Preparation HTML

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

<div>click</div>

Test runner

Ready to run.

Testing in
TestOps/sec
no this
$('div').bind('click', function() {
 return window;
});
ready
passing this
$('div').bind('click', {
 self: this
}, function(event) { // <-- see!
 return event.data.self;
});
ready
proxy
var foo = function() {
 return this;
};
$('div').bind('click', jQuery.proxy(foo, this));
ready

Revisions

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

  • Revision 1: published by cody lindley on
  • Revision 2: published by Rick Waldron on
  • Revision 3: published by ajpiano on
  • Revision 4: published by ajpiano on