Jaa


A Quick Comparison Between jsViews and Knockout

Both jsViews and Knockout are JavaScript libraries for implementing an MVVM pattern on the client side using the jQuery templates plugin or the later version of same, jsRender.

When trying to choose which of these libraries to use for some projects I made a quick list of the pros and cons of each and thought it might be useful to others when they are doing the same.

So without further delay, here is my list for Knockout so far:

Pros

Cons

Declarative binding for events is easier for some within the templates themselves rather than using selectors and code behind Requires you to use ko.observable(data) calls to convert your view model data into something usable by the binding engine
Has excellent documentation and examples Requires you to call your view model properties as functions when you access them. If you forget, it breaks the binding and silently fails (at least in the version I was using). This is bad when you assign values and forget to add the parenthesis because you wipe out the observable binding information.
Binding common elements is quite easy and the syntax is simple. Purists will note that declarative event binding within the templates violates separation of concerns

And for jsViews:

Pros

Cons

Uses raw data view models without need of conversion or wrapping Requires explicit “observable” update calls for data changes in code (binding still works without issue… I’d equate this to Knockout requiring parenthesis on all the view model properties because it makes them functions)
Is very lightweight and fast There is little in the way of documentation and there are few samples aside from Boris’ GitHub repository
Uses jsRender out of the box without modification Has no event binding capability (some, including me like using jQuery.on() instead of Knockout syntax for this so this could be a Pro to some)

No matter which of these you choose to use, they both have the MVVM pattern covered if used properly. At present it seems to be a choice based on personal preference. I welcome any comments or suggestions for additions to my lists.

Comments

  • Anonymous
    December 04, 2012
    Thanks for putting this out there. A nice little 'reference card' if I may :)

  • Anonymous
    December 06, 2012
    Thanks. How about using Links to the mentioned libraries in the text?;)