Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference in history implementation by backbone.js, davis.js and history.js

All these 3 libraries allow to manipulate history object. OK, backbone does a lot of more but let consider only it history part.

  • http://documentcloud.github.com/backbone/#History
  • https://github.com/olivernn/davis.js
  • https://github.com/browserstate/history.js

What is a difference between these 3 implementation?

like image 391
Wojciech Bednarski Avatar asked Dec 01 '11 23:12

Wojciech Bednarski


People also ask

Why use Backbone JS?

BackboneJS allows developing of applications and the frontend in a much easier way by using JavaScript functions. BackboneJS provides various building blocks such as models, views, events, routers and collections for assembling the client side web applications.

Which method can be used to manipulate the backbone JS history?

There is only method named "start" can be used to manipulate the Backbone. js history.

How does Backbone JS work?

Backbone. js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

Is backbone a MVC?

Backbone is a JavaScript MVC library and that's a key difference. In the JavaScript MVC context, a framework usually means that you need to configure your code to get things done. Maybe you need to add some code to your HTML page, or give a page element a certain ID class name.


1 Answers

History.js is more of a polyfil for browsers that do not natively support HTML5 pushState and for ironing out the differences between different browser implementations of pushState.

Davis.js is a routing layer, primarily on top of pushState (although this can be switched out easily to hash routing). It gives you a simple api to define and respond to routes within your application.

Backbone's router is similar to Davis, however it tries to automatically fall back to hash based routing when pushState is not available.

As the author of Davis I'm slightly biased but I think the Davis api is slightly nicer and more powerful than backbones. I also think that trying to gracefully handle falling back to hash based routing when pushState is not available is not worth the effort and complexity that it can introduce.

like image 159
Oliver Nightingale Avatar answered Oct 23 '22 18:10

Oliver Nightingale