Cross browser event
JavaScript performance comparison
Preparation code
<script type="text/javascript">
var pseudoEvent = document.createEvent('MouseEvents');
pseudoEvent.initEvent('click', true, true);
</script>
<div id="testDiv">
</div>
<script>
Benchmark.prototype.setup = function() {
function testTypeof(e) {
if (typeof e == 'undefined') {
e = window.event;
}
if (typeof e.target != 'undefined') {
var output = e.target;
} else {
var output = e.srcElement;
}
}
function testBooleanOutput(e) {
if (typeof e == 'undefined') {
e = window.event;
}
var output = e.target || e.srcElement;
}
function testInline(e) {
if (typeof e == 'undefined') {
e = window.event;
}
var output = e.target ? e.target : e.srcElement;
}
function testBooleanIO(e) {
if (!e) {
e = window.event;
}
var output = e.target || e.srcElement;
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
testTypeof |
|
pending… |
testBooleanOutput |
|
pending… |
testInline |
|
pending… |
testBooleanIO |
|
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 Diggo11
- Revision 2: published by Diggo11
- Revision 3: published by tiffon
- Revision 5: published by tiffon
0 comments