SendHub has put up a post on things its developers learned in rebuilding the front-end of its Web site as a single-page application with Backbone.js. This includes everything from template rendering to "avoiding a zombie apocalypse."

The company decided to give a facelift because "the site looked a bit dated, and it just didn't feel as snappy as we wanted it to. All pages were rendered almost entirely on the server, and only a couple of places used Ajax to pull in data asynchronously." The company also wanted to test out its developer API>.

Because Backbone.js has a dependency on Underscore.js, they decided to use it over Mustache, Handlebars and other rendering libraries. This turned out to be a good choice because it not only saved them from having to load an additional library, they also didn't need the extra features provided by the other libraries.

Killing Zombies

Another "big learning opportunity" in building the new front-end, was "in understanding the importance of killing zombies." In this case, we're talking about objects that "you can't access directly, but live inside the application and take up memory resources." Basically, SendHub says these crop up "when you forget to clean up event listeners after objects are removed from the page (usually they are view objects)."

The best zombie-killing resource, according to SendHub, is Derick Bailey's "Zombies! Run! (Managing Page Transitions In Backbone Apps)", which explains how to use a close method to avoid zombies.

SendHub also talks about how to use a global dispatch object to get Backbone.js views talking to one another, "without tightly coupling them to each other."

If you're new to Backbone.js, SendHub's post is worth reading.