JavaScript performance comparison

Revision 2 of this test case created by Erick Ribeiro

Preparation code

<button id="button1">
  Click here
Benchmark.prototype.teardown = function() {
    document.getElementById("button1").onclick = function(){};

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);
function outside addEventListener
function test() {
  var x = 1;
  var y = 2;
  alert(x + y);
document.getElementById("button1").addEventListener("click", test, false);

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment