The Source

You can check out the code from the Coherent project on Google Code. All you need is Subversion and you’re on your way. To get the latest copy of the code, you can check out the trunk:

svn checkout http://coherent.googlecode.com/svn/trunk/ coherent

You’ll need to install the distil tool to build the project. DIstil is distributed as a Ruby gem, so you install it in the usual way:

sudo gem install distil

Then, you can build everything:

cd coherent
distil

And you’re done. In the build folder are four versions of the coherent library:

coherent-debug.js
This is the debugging and development version of the library. Using this version makes it easier to track down errors, especially if you’re hacking on the Coherent source itself.
coherent-uncompressed.js
This is a single file that contains all the source files from the Coherent library concatenated in the correct order.
coherent.js
This is the concatenated and minimised version of the library. This is ideal for deploying into production, because it’s small and will download quickly.
coherent.js.gz
This is the same file as coherent.js except it’s already gzip encoded to reduce the load on your server.

Including Coherent

If you’re using Distil to build your project, including coherent is easy. Just add a reference to coherent-uncompressed.js to your Javascript sources and your output files will include all of coherent.

For example, the distil.yml file from the sample application looks like this:

# This is the main target for your application. This target will yield optimised
# CSS and Javascript files for all of your assets. In addition, it will emit
# uncompressed and debug versions which are useful during development.
all:
    js:
        # Your main Javascript assets, specified in order they should be loaded.
        # The final entry loads all Javascript assets in the src/js folder and
        # uses the import statements to compute the dependency order.
        - coherent-uncompressed.js
        - src/js/sample.js
        - src/js

Distil will first include the uncompressed version of the coherent library, then the file sample.js, then any other Javascript files in the src/js tree. Because everything is packaged up in one file, your page will load faster.