Enhance Speed of your web app with Backbone.js

Enhance Speed of your web app with Backbone.js

Backbone.js is a popular open source JavaScript framework that allows us to develop single page web application. It offers a MVC framework for organizing Javascript application.

backbonerails-new1

 

 

 

 

 

 

 

 

What is Backbone.js?

  • Building single-page web apps or complicated user interfaces will get extremely difficult by simply using JQuery alone. Because JavaScript libraries are great at what they do, without realizing it you can build an entire application without any formal structure. Whereas Backbone.js is a lightweight framework that allows us to create single page applications in a structured manner. Backbone.js enforces that communication to the server should be done entirely through a RESTful API. The web is currently trending such that all data will be exposed through an API, because the browser is no longer the only client, now we have mobile devices, tablets and electronic fridges etc.
  • Website speed is the demand of the day. Running a website with full server dependencies, is not cost effective in terms of speed. If for each and everything we depend upon server and every request is served with a page refresh, then it will be annoying to any user. If you use MVC client architecture like Backbone.js, then most of the load on server is reduced and the website is depends on server only for getting json data and not for the logic of how to display it.
  • Better user experience is needed for every website that wants more and more users to visit it. And Backbone.js provides a very good user experience, as the demand of the users are served only in the client machine. User does not need a page refresh for any action.

Advantages of Backbone.js

  • Streamlined Event handling
    When a project grows, the jQuery declarations and callbacks gets more complex. The code becomes more cluttered. Backbone.js overcome this problem by providing an event-driven communication between views and models. The backbone.js events build on top of regular DOM events, which makes the mechanism very versatile and extensible.
  • Syncing with a back-end
    The models in Backbone.js can be easily tied to a back-end. The framework provides excellent support for RESTful APIs in that models can be mapped to RESTful endpoints.
  • Maintainability by following conventions
    Conventions are a great way to introduce a common coding style without the need of coming up with an extensive set of coding standards. Backbone.js is particularly helpful to maintain a clean code base despite having multiple developer involved in the coding.
  • Organized Code
    Backbone.js is a client-side MVC architecture. It is a design pattern where we separate the data from the way it is defined, manipulated and displayed. It allows you to structure your Javascript code in an MVC pattern.
  • Speed
    In the MVC platform, web application depends upon server for getting json data for the logic on how to display it. Here load on server is reduced and it helps in increasing the speed of the website.
  • Reduced data transfer
    Normally when client searches a record from the database, it sends a request to server.And then, to render output, database starts processing and send response.
    Server -> database processing-> rendering output-> Response
    But with Backbone.js request will be sent only for data and data will be returned from server in json format. Those data is manipulated at client-side.

 

In essence the backbone is the way to structure your application better. You can easily organize client side ‘JavaScript’ code into MVC pattern of Rails applications. Check out implementation of ‘Backone.js’ into Rails applications.

We have implemented numerous Rails applications with backbone.js. Two out of them are KurrentJobs and OrangeGigs.

Please share your experience of implementation of Backbone.js in Rails.

 

Avatar
Srikant M. Mohapatra
anurag.pattnaik@andolasoft.com
Shares