Description #
Backbone.js is a minimal JavaScript library that provides structure to web applications by offering models, collections, and views tied together with events.
History #
Backbone.js was created by Jeremy Ashkenas in 2010. It became one of the earliest libraries to formalize JavaScript MVC (Model-View-Controller) patterns for the web and was widely used in early single-page applications.
Hello World Code #
var Hello = Backbone.Model.extend({
defaults: {
message: "Hello, World!"
}
});
var hello = new Hello();
alert(hello.get("message"));
How to Run #
Option 1: Online
JSFiddle with Backbone.js
Option 2: Local
Install via CDN:
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.4.1/backbone-min.js"></script>
Key Concepts #
- Models with observable attributes
- Views tied to DOM elements
- Collections of models
- RESTful JSON sync
- Event-driven design
- URL routing with
Backbone.Router
- Dependency on Underscore.js
- DOM manipulation via jQuery
- Lightweight and unopinionated
- Extendable for larger architectures
Try It Online #
https://jsfiddle.net/boilerplate/backbone
Fun Facts #
Backbone.js powered early versions of sites like Trello, Airbnb, and LinkedIn before the rise of Angular and React.