Removing jQuery event properties

JavaScript performance comparison

Revision 3 of this test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var props = $.event.props;
</script>
    

Preparation code output

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
join, replace, and split
// reset
$.event.props = window.props;
// remove layerX and layerY
$.event.props = $.event.props.join('|').replace('layerX|layerY|', '').split('|');
pending…
Using $.map
// reset
$.event.props = window.props;
// remove layerX and layerY
$.event.props = $.map($.event.props, function(prop) {
  return prop === 'layerX' || prop === 'layerY' ? null : prop;
});
pending…
while loop + delete
// reset
$.event.props = window.props;
// remove layerX and layerY
var props = $.event.props,
    length = props.length;
while (length--) {
  var el = props[length];
  (el === 'layerX' || el === 'layerY') && delete props[length];
}
pending…
while loop + new array
// reset
$.event.props = window.props;
// remove layerX and layerY
var all = $.event.props,
    len = all.length,
    res = [];
while (len--) {
  var el = all[len];
  if (el !== 'layerX' && el !== 'layerY') res.push(el);
}
$.event.props = res;
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.

0 Comments