talira

Backbone.js

Models, collections, views and a router that give structure to JavaScript web apps

open sourceMITfree

Backbone.js gives structure to client-side web applications with a small set of primitives: models with key-value binding and custom events, collections with a rich set of enumerable functions, views with declarative event handling, and a router for bookmarkable URLs using the History API or hash fragments. It connects to an existing API over a RESTful JSON interface, so when a model changes, the views that show it re-render themselves instead of the app updating the DOM by hand. Its only hard dependency is Underscore.js; jQuery is needed for RESTful persistence and DOM work in views. The production build is about 8 KB packed and gzipped. It was created by Jeremy Ashkenas as an open source component of DocumentCloud.

Problems it solves

  • my JavaScript front end is a tangle of jQuery selectors and callbacks keeping data in sync
  • keep my views in sync with data from a REST API without writing DOM glue code
  • add structure to a jQuery app without moving to a big framework

Features

  • Models with key-value binding, validation and change events
  • Collections with enumerable functions (map, filter, sort and more)
  • Views with declarative event handling
  • Router with History API (pushState) or hash URLs
  • Syncs models with a RESTful JSON API
  • About 8 KB packed and gzipped

Limitations

  • Needs Underscore.js, and jQuery for RESTful persistence and DOM manipulation in views1

Alternatives

The same job

These do what Backbone.js does.

  1. Mithril.js Small client-side JavaScript framework for single-page apps, with routing and XHR built in

Compare Backbone.js with the top 3