Evaluating Javascript Performance

Posted by Tejus Parikh on February 25, 2009

There’s a lot of factors that you have to take into account when you pick a javascript framework. Picking the right tool is a balance of developer familiarity, the task at hand, and performance. Measuring a framework’s performance is tricky. The reality is that no benchmark will account for what your app will do in real life. Making the task harder is that each framework has different features, making a straight head-to-head comparison impossible. However, that doesn’t mean we don’t need to know the relative speed of different frameworks. I found myself in that position recently. I attempted to gauge the relative speed of Mootools, JQuery, Prototype, and Appcelerator. The rational behind picking these four frameworks is that I understood them enough to create a simple test.

the benchmark

The bechmark that I wrote is a rails app and available on GitHub. The README describes what it does:
This pretty simple test attempts to measure the time it takes to load the framework and do some basic tasks. The first is to load the page with the W3C css selector page pre-loaded into a hidden div. It then dynamically loads in the Georgia 2008 Presidential election results, again in a hidden div. Next it loads in the Georgia 2008 Senate results and attaches a click event to all the red elements. Finally, it loads in the Georgia 2008 election summary. All files are served from the local server to avoid mistimes due to network latency. Because of the way Appcelerator works, instead of using a selector to attach an event, I’ve created a different version of the “dynamic” html file with “on” expressions set for the red elements. I feel this test is more fair, since there’s no reason to select through the dom when Appcelerator processes each element by default. This is a rails app, so you should just be able to download it, then run script/server. Navigate to localhost:3000 and you’ll be good to go. Feel free to fork and improve as you see fit.


I ran the benchmarks on my Windows XP vm, with 384MB of RAM running within VMWare Fusion on a 2.2GHz Macbook Pro. These are the times. Appcelerator is included twice. The first is an internal patched version. The second is the latest 2.2.1 release. Columns in Red indicate that an error occurred while running the test.
Test (all times in ms)FirefoxSafariChromeIE
Framework Loaded in8035922431
DOM Loaded in1271567155109
Load Large File24779164141
Dynamic Large File179104135703
Crazy-Large File38285721363985
Framework Loaded in11160517141
DOM Loaded in58102831
Load Large File234198249563
Dynamic Large File4742092271187
Crazy-Large File105586122183922
Framework Loaded in4854147485
DOM Loaded in45114462
Load Large File3191421903813
Dynamic Large File2751701242329
Crazy-Large File1697932129324877
Appcelerator (internal)
Framework Loaded in190234timeout281
DOM Loaded in870341timeout2485
Load Large File1241501timeout24237
Dynamic Large File1086578timeout31331
Crazy-Large File201962772timeout595237
Appcelerator (2.2.1)
Framework Loaded in343425timeoutError
DOM Loaded in1067748timeoutError
Load Large File31452053timeoutError
Dynamic Large File24201253timeoutError
Crazy-Large File178146780timeoutError


Safari is incredibly fast. If all your users used Safari, the framework you use doesn’t really matter. I’m pretty surprised with how fast Prototype was in IE. It was the only one that was quicker in IE than in FF. Mootools and JQuery had similar performance, right up until it came time to load a very large file in IE. No framework was the clear winner on speed. Hopefully this benchmark provides a little guidance on which framework to pick. If all you’re doing is catering to Safari users, feel free to go with something like Appcelerator. If you need to target IE users or the general web population, you can’t go wrong with Prototype, Mootools or JQuery, unless you’re loading in very large files, at which point Mootools is out. Otherwise, pick for which one you like better.

Tejus Parikh

Tejus is an software developer, now working at large companies. Find out when I write new posts on twitter, via RSS or subscribe to the newsletter: