Sam Stephenson has recently released a Javascript preprocessor called Sprockets. It’s distributed as Ruby gem, and it helps to declare scripts dependencies through special comments, and safely build them one script. It’s very useful for maintain your Javascript projects, extract reusable code and share across applications.

Installation

$ (sudo) gem install sprockets It will also install sprocketize executable.

How it works?

To declare a dependency use require directive:
//= require //= require "cookies" When you use angular brackets the script will be searched in all the Sprockets load path, if you use quotes instead, you are forcing to load the file from the current directory. Usually you should use the first way to require frameworks or libraries and the second one for your scripts.