Commons JS – Improving Client-Side JS by Improving Server-Side JS
The Commons Packages API enables developers to define metadata for a module in a consistent way (through a package.json file), for example the name, description and version of the package. More importantly, it enables the author to declare dependencies on other packages, which paves the way for automated package management. Node’s package manager (npm) is widely used for server-side packages but package managers for client-side libraries also exist (e.g. VoloJS and JamJ). These enable client-side developers to more easily manage the large number of 3rd party libraries needed for large-scale web development.
As a final example, JQuery developers (since version 1.5) have been using the Deferred object, which is returned from jQuery.ajax(). The Deferred object is based on the CommonsJS Promises/A specification, which in turn was inspired by the Deferred object in Dojo. Having a common API for registering callbacks for asynchronous functions is a benefit because different frameworks will have common approaches to AJAX calls, which makes it easier for developers to learn the framework more quickly.
Categories: Best Practices