Why To Use Pure JavaScript

JavaScript performance comparison

Test case created by Kent

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var my_array = ["one", "two", "three"];
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Pure JS
for (var i = 0, max = my_array.length; i < max; i++) {
  console.log(i + ':' + my_array[i]);
}
pending…
jQuery
$.each(my_array, function(index, value) {
  console.log(index + ':' + value);
});
pending…

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

Compare results of other browsers

0 comments

Add a comment