Editing How to write up to 98% faster JavaScript code. This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) 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](https://github.com/DominikGuzei/Compact.js) that is based on [Require.js](http://http://requirejs.org/) Dominik Guzei [Wizzart](http://wizzart.at) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <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> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code var a = window.c = {}; (a.e = {}).add = function(d, e) { return d + e }; a.a = {}; for (var b = new a.a.b(1); b.value < 1E5;) b.d(1); Test 2 Title Async (check if this is an asynchronous test) Code define("Library.util.add", function() { return function(a, b) { return a + b } }); define("Library.cool.Class", ["Library.util.add"], function(a) { function b(a) { this.value = a } b.prototype.a = function() { this.value = a(this.value, 1) }; return b }); require(["Library.cool.Class"], function(a) { for (a = new a(1); a.value < 1E5;) a.a() });