jQuery Event this (v4)

Revision 4 of this benchmark created by ajpiano 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;
});

$('div').trigger('click');
ready
passing this
$('div').bind('click', {
 self: this
}, function(e) {
 return e.data.self;
});

$('div').trigger('click');
ready
proxy
var foo = function() {
 return this;
};
$('div').bind('click', jQuery.proxy(foo, this));

$('div').trigger('click');
ready
proxy once
var foo = $.proxy(function() {
 return this;
}, this);
$('div').bind('click', foo);

$('div').trigger('click');
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