addEventListener

JavaScript performance comparison

Test case created by Erick Ribeiro

Preparation code

<button id="button1">
  Click here
</button>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
function inside addEventListener
document.getElementById("button1").addEventListener("click", function() {
  var x = 1;
  var y = 2;
  alert(x + y);
}, false);
pending…
function outside addEventListener
function test() {
  var x = 1;
  var y = 2;
  alert(x + y);
}
document.getElementById("button1").addEventListener("click", test, false);
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:

0 comments

Add a comment