Knockout is the simplest of all the frameworks as well as one of the smallest. It does not claim to be able to solve all your problems, but it does claim to do a few useful things (see “features” below) and do it better than the alternatives. In the words of Knockout creator Steve Sanderson, it is “low risk” because its uses are focused and it is compatible with any other technologies you are using and you can use it in a very small part of your application or your entire application. For someone who wants to take their project to the next level without too much risk, knockout is a great choice.

Features

-Model-View-ViewModel architecture
-Tracks changes in your data by wrapping all your variables in an “observable function” creating a dependency graph which automatically controls the flow of events when something changes in your application.
-DOM or String-Based Templating for modularizing view and rendering them programmatically

Strength of the Project and Community

The Knockout project was released by Steve Sanderson (who is now on the Microsoft ASP.NET team) back in 2010 before he came to Microsoft. Since then a second version has been released, there have been a number of plugins written for it, Microsoft has incorporated intellisense support for it into Visual Studio 2012, and developers Michael Best and Ryan Niemeyer have joined the core Knockout.js development team. As a rough estimate of the size of the community, there are currently 3,533 people who have starred the KO GitHub repository, and 5,055 stack-overflow questions with knockout tags.

Ease of Learning

The documentation for knockout is probably the best we have ever seen. It has an amazing interactive tutorial system, live examples, and the documentation is extremely comprehensive and easy to understand. For most developers already familiar with javascript it should not take more than a few days to get up and running.

Compatibility and Extensibility

Knockout is compatible with any back-end technology and on the front-end it does as much or as little as you decide. Knockout purposely leaves many decisions to the developer to decide letting developers pick the best tool to meet their specific needs. Knockout has no opinion about how you communicate with the server or how you choose to do routing, but there are several third party libraries that do a fine job of these things (like sammy.js for routing and upshot.js for data-access). Knockout is one of the only frameworks that actually offers support for IE 6 if that is something you are interested in. It goes without mentioning that it works fine next to JQuery. Knockout is easily extensible. To modify or extend the default functionality, Knockout offers a features like custom bindings, and custom functions. As mentioned above, there are also several plugins already written for knockout.

Testing and Debugging

As of now, we have not seen any specific debugging tools for knockout, but it works fine with Javascript testing tools such as jasmine.  Console.log() is handy, and knockout also offers a function ko.toJSON() which converts a KO view model to JSON and can be bound to a text area somewhere on the page so that developers can see in real time how their data is changing. For testing and prototyping, we find that it is easy to use implement knockout applications in jsfiddle.

Pros

-Highly compatible with other 3rd party js libraries
-Easy to learn and use
-Dependencies are handled through a dependency graph which targets specific data as opposed to updating entire models when data changes like in Angular.js. This may increase performance in data-heavy applications compared to “dirt checking” which Angular uses (but see this post on Stack Overflow which defends Angular’s approach).

Cons

-All javascript variables and arrays are functions (aka KO observables) as opposed to angular which can be a little confusing at first for some people. But it should be noted that all native javascript array functions like splice(), indexOf(), push() etc. are implemented by Knockout and may be used on KO observables.
-HTML views can get messy as declarative bindings increase. This can be mitigated to some extent through the use of custom bindings, computed observables and by attaching events to the DOM using JQuery (see Unobtrusive Event Handling) instead of using the data-bind attribute.
-Additional functionality like data-access and url-routing are not included. If you are looking for an end to end solution that offers a complete toolbox of common web-app functionality, you should probably check out frameworks like Angular or Ember.

Back to Part I
Link to Part III