Backbone.js – An Overview

Backbone.js –

BackboneJS is light weight library of Javascript in structured manner to handle client side approaches. It is helpful to create single page application which runs on web browser. BackboneJS provides model, views and collection to create application. It follows MVC structure and makes the code isolated. Jeremy Ashkenas developed it and preliminarily released on October 13, 2010.

Uses of BackboneJS –

When we create any web application use lots of line of JavaScript to handle things client side which creates hassle to maintain and understand the code.

BackboneJS provides lots of features and well organized structure to manage the application and reduce the line of codes.

Backbones works with events which manage request separately and keep the code clean and organized.

Dependencies –

There are 2 JS on which backbonejs is dependent.

Jquery.js: Less dependency

Underscore.js: Highly dependent.

Structure –

BackboneJS provides a well manage and separate structure for UI and business logic with following modules.

  • Http Request
  • Router
  • View
  • Events
  • Model
  • Collection
  • Sync
  • History

1. Http Request: Every time when a user performs any action then http request is generated for http server.

2. Router: In the base of http request router decides for correct router for the view and also maintain the URL. Backbonejs can customize the user like what will be the actual URL and what will display to the users. URL rewriting is supported by backbonejs.

3. View: View is responsible to represent model data to users (how and what data will display). Model data render on view with the help of events and view communicate with users and handle all type of events like input and bind events.

4. Events: Events are the main part and can mix up with object. It is the module that can provide ability to the objects to bind with custom events and triggered on them. Events should be declared after bind.

5. Model: Model is responsible to handle data and perform manipulation on the data and also logical part. It is also called heart of application. Model gets data from server and stores data on server.

6. Collection: Collection is responsible to manage model. Collection performs manipulations on model like new model creation, changes on model and computation on multiple models in a same time.

7. Sync: It communicates between model and data source. It is the mediator between server and model or collection.

8. History: It is responsible for maintain URL history (routes) that from where we are coming and where we will go.

Features –

1. Provide maintained and organized structure to write JavaScript code.

2. It is simple provide separation between business logic and user interface.

3. Any changes on model will automatically reflect on related view.

4. It is open source library and available free of cost with more flexibility.

5. Backbonejs can integrate with any existing application.

Leave a comment