Introduction

If you are looking for a lightweight framework for building JavaScript web applications, Spine is the answer. This is a framework that will give you a great MVC structure and then it gets out of the way, which allows you to better concentrate on all of the fun stuff like building great website applications.

When it comes to the approach to web application design and architecture, Spine is very opinionated. The architecture works to complement patterns like CommonJS modules, and decoupled components, which help with both code quality as well as maintainability.

The library may be written in CoffeeScript, however it does not necessarily call for CoffeeScript to be able to develop the applications. You have the ability to use JavaScript or CoffeeScript, whichever language may be the most familiar to you.

Spine is also pretty small, with the core library having about 600 lines of CoffeeScript. Being so simple and lightweight is fundamental to Spine, and the only dependency it has is zepto or jquery.

Core Values

  • MVC – The model view controller, or MVC pattern, is right at the hart of the all Spine apps. It works to be sure that your application is name-spaced, modular and never descends into a mess of view and model logic because there is consistent architecture. While it is great for teams, it also brings well-needed structure to all of your JavaScript development.
  • Asynchronous Interfaces – There are too many JavaScript applications and frameworks that do not take full advantage of client-side rendering power. The end users will not care if the background requests to their server are pending, and they never want to see spinners and loading messages. Users always want interfaces that are unblocked and interaction that is instant. To have this, Spine works to store and render everything on the client-side, communicating with their server asynchronously.
  • Simplicity – Spine offers maximum possible viable product. This means it never dictates your views, CSS, or HTM. It is not a massive framework that has dozens of different widgets. The goal is to just get out of the way to allow you to let go and do what it is that you do best, like building great web applications.

Why Should You Think About Using Spine?

You can look at JavaScript frameworks as being like a dime a dozen, with more popping up each day. What is it that makes Spine special?

  • Real world environment built in
  • Controller implementation that is lightweight, originally based upon Backbone’s API
  • ORM and full model layer
  • HTML5 and Ajax local storage adapters
  • Asynchronous server communication
  • Works for all major browsers like Safari, Firefox, Chrome and IE >= 9
  • Lightweight and simple
  • Approachable source code
  • Minimal dependencies
  • Wonderful documentation

But, you should never take our word for it, just look at the source of example applications and you can decide for yourself.

Components

  • Spine – You will find the main library has the core classes like Controller and Model
  • Extension Modules – Routing, two way binding, model relationship management and more
  • Spine Mobile – This is the mobile extension, allowing you to easily build your PhoneGap and mobile applications that are currently searching for a maintainer
  • Spine.app – This is an easy way for you to generate spine applications
  • Hem – This is Spine’s optional dependency manager/development server

CoffeeScript

Spine gets written in CoffeeScript, which is a little language that turns into JavaScript. You never have to write your Spine applications in CoffeeScript, as regular JavaScript will work just fine. However, when you use CoffeeScript, it will be the path of least resistance and one that we personally recommend.

CoffeScript may not be for everyone and there is no doubt that some people will turn off the framework. However, if there are any issues with the language, you can give it a chance and check it out. It is important to know what you are missing, as CoffeeScript has a whole lot to offer.

See the Little Book for CoffeeScript if you want more information on the language.

Documentation with Spine will cater to developers of both CoffeeScript and JavaScript, so you can toggle your source code examples between both using silver handles. Alternatively, the language can be toggled site-wide just by using the language selector that you will find in the top right of your documentation.

Spine is fairly straightforward. The library is small and you will find API minimal. The concepts can be a bit tricky at first, as dealing with everything client side can all be a bit of a learning curve. For this very reason, the docs will read more like a guide than raw API documentation. Once you are familiar with the library, pure API documentation is also available.

For anyone new to Spine, check out these guides:

  • Classes
  • Controllers
  • Models
  • Views

You can then experiment with getting started and learning more about generating apps and using HEM.

Spine was build with a book by O’Reilly called JavaScript Web Applications. This is a really great introduction to dependency management, MVC, testing and templates. All of which are very useful concepts no matter which framework you use.

Download it here -> http://oreilly.com/catalog/0636920018421