jQuery VS Zepto VS Angular jqLite

JavaScript performance comparison

Revision 178 of this test case created

Info

This is an edited test from http://jsperf.com/jqm3/68 by levin, which is based on some other test.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script src="//code.jquery.com/jquery-git2.min.js"></script>
<script src="//zeptojs.com/zepto.min.js"></script>
<script src="//fastjs.net/js/fast.min.js"></script>
<script src="//rawgithub.com/01org/appframework/master/appframework.min.js"></script>
<script src="//bytes1.dyndns.org/BSI/website-app.js"></script>


<div id="container"></div>
<script>
Benchmark.prototype.setup = function() {
    var container = document.getElementById('container');
    var ul, li, i = 0;
    var msg = "Hello World ";
   
    var div = document.createElement('div');
   
    function htmlToFragment(html) {
      div.innerHTML = html;
      var fragment = document.createDocumentFragment();
      for (var i = -1, c = div.childNodes.length; ++i < c;) {
        fragment.appendChild(div.childNodes[i]);
      }
      return fragment;
    }
};

Benchmark.prototype.teardown = function() {
    container.innerHTML = "";
};
</script>

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
jQuery
ul = jQuery("<ul>");
for (; i < 100; i++) {
  ul.append("<li>" + msg + "jQuery</li>");
}
jQuery(container).append(ul);
pending…
Intel App Framework
ul = af("<ul>");
for (; i < 100; i++) {
  ul.append("<li>" + msg + "AppFW</li>");
}
af(container).append(ul);
pending…
Zepto
ul = Zepto("<ul>");
for (; i < 100; i++) {
  ul.append("<li>" + msg + "Zepto</li>");
}
Zepto(container).append(ul);
pending…
Angular jqLite
ul = angular.element("<ul>");
for (; i < 100; i++) {
  ul.append(angular.element("<li>" + msg + "Angular</li>"));
}
angular.element(container).append(ul);
pending…
BSI
ul = BSI.makeNode("ul");
for (; i < 1; i++) {
  ul.append(BSI.util.makeDOMFragment("<li>" + msg + "BSI</li>"));
}
BSI.Node(container).append(ul);
pending…
fastjs
ul = f.create("<ul>");
for (; i < 100; i++) {
  f.append(ul, f.create("<li>" + msg + "FastJS</li>"));
}
f.append(container, ul);
pending…
"native"
ul = htmlToFragment("<ul/>");
for (; i < 100; i++) {
  ul.appendChild(htmlToFragment("<li>" + msg + "'native'</li>"));
}
container.appendChild(ul)
pending…
Native
ul = document.createElement('ul');

for (; i < 100; i++) {
  li = document.createElement('li');
  msg = document.createTextNode(msg + 'Native');
  li.appendChild(msg);
  ul.appendChild(li);
}

container.appendChild(ul);
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:

0 comments

Add a comment