minified vs. minified

JavaScript performance comparison

Test case created by John-David Dalton


I noticed subtle changes in the way the file is minified could affect the performance of Safari.

In this case, the "slow" version has typeof checks done like:

"number" == typeof x

and the "fast" version has typeof checks done like:

typeof x == "number"

Preparation code

<script src=""></script>
var dev = _.noConflict();
<script src=""></script>
var fast = _.noConflict();
<script src=""></script>
var slow = _.noConflict();
Benchmark.prototype.setup = function() {
    var dev  =;
    var fast =;
    var slow = window.slow;
    var numbers = Array(100);
    for (var index = 0; index < 100; index++) {
      numbers[index] = index;

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
var result = dev.contains(numbers, 50);
var result = fast.contains(numbers, 50);
var result = slow.contains(numbers, 50);

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

1 comment

John-David Dalton (revision owner) commented :

Keep in mind if you're running a jsPerf test from within your iOS Twitter client app or other WebView you're running without JIT enabled. Try running this jsPerf in Safari mobile instead.

Comment form temporarily disabled.

Add a comment