How to write up to 98% faster JavaScript code.
JavaScript performance comparison
Info
This test shows that if you are not a JavaScript Ninja your framework code could have been up to 98% faster (Firefox) as when it was written in a string based modular fashion like it is used by Compact.js that is based on Require.js
Dominik Guzei Wizzart
Preparation code
<script>
(function() {
var f = {},
g = Array.prototype.slice;
window.define = function() {
var a = arguments,
d = a[0],
b = null;
a = g.call(a, 1);
if (a.length > 1) {
b = a[0];
for (var c = [], e = 0; e < b.length; e++) c[e] = f[b[e]];
b = a[1].apply(this, c)
} else b = a[0]();
f[d] = b
};
window.require = function() {
var a = arguments,
d = [],
b = null;
a.length > 2 && (a = g.call(a, 1));
d = a[0];
b = a[1];
a = [];
for (var c = 0; c < d.length; c++) a[c] = f[d[c]];
b.apply(this, a)
}
})();
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Global namespace chain |
|
pending… |
Local string based modules |
|
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 Dominik Guzei and last updated
- Revision 2: published by Micheil Smith
- Revision 3: published by eric
- Revision 4: published by dnolen
- Revision 5: published by dnolen
- Revision 6: published by Jie
- Revision 7: published by Tom Schuster
- Revision 9: published by eric
- Revision 10: published by eric
- Revision 11: published by Dominik Guzei
- Revision 12: published and last updated
0 comments