Choosing a JavaScript framework

Luke Canvin

Screenshot of the Backbone homepage

One of the most important elements of a modern web application is the JavaScript that powers the client-side interactions. It is what gives us AJAX for subtle server interaction; powerful manipulation of the web page’s structure; and attractive animations and effects that users come to expect from high-quality web sites.

All that JavaScript can lead to a mess of script files, functions and variables, which becomes harder to manage as the application advances. To combat this a range of JavaScript frameworks have emerged to give developers structure and the basic objects they might need when creating a complex web application.

For the Dev Camp we looked at several popular frameworks, all based loosely around the common Model-View-Controller (MVC) structure for apps, though they all have their own takes on exactly how that is implemented. Three of these frameworks stood out:

  • Backbone.js uses models, collections, view and routers
  • Spine has a pretty standard MVC pattern
  • Knockout users models, views and view models

Backbone and Spine are fairly similar and Backbone seems to have more of a following so we let the popularity make the choice for us between that pair. Choosing between Backbone and Knockout was trickier:

  • Backbone has a reputation of having a pretty steep learning curve, whereas Knockout gets you up and running quicker.
  • Knockout has some nice automatic data binding whereas Backbone has a little more manual boilerplate.
  • Backbone copes much better with more complex applications whereas Knockout begins to require more thought and refactoring as you go on.