1 [Jam][] is a package manager for front-end [JavaScript][]. While you
2 want to use [[npm|Node]] for server-side stuff, Jam is the tool to use
3 for JavaScript that you'll be sending to your users. Following the
4 [docs][] (with my already-configured [[`~/.local` prefix|Node]]):
8 Integrating with Django is a bit tricky, especially since Jam doesn't
9 manage the CSS, images, … that are often associated with JavaScript
10 libraries. If you need that, you probably want to look at [[Bower]]
13 Write a setup `package.json` defining your project's dependencies:
18 "description": "An example project"
20 // NPM dependencies go here…
24 "packageDir": "apps/my-app/static/js/",
25 "baseUrl": "apps/beehive_common",
27 // Jam dependencies go here…
34 Install your dependencies with:
42 Compile just the bits you use into a single require-able replacement.
44 $ jam compile apps/my-app/static/js/require.js
46 This last bit is really cool, and where a less JavaScript-oriented
47 tool like [[Bower]] falls short. [Jam is using][jam-compile] the
48 [RequireJS optimizer][optimizer] under the hood for the task, so if
49 you don't use Jam you can always run the optimizer directly.
51 [[!tag tags/programming]]
55 [Jam]: http://jamjs.org
56 [JavaScript]: http://en.wikipedia.org/wiki/JavaScript
57 [docs]: http://jamjs.org/docs
58 [jam-compile]: https://github.com/caolan/jam/blob/master/lib/commands/compile.js#L8
59 [optimizer]: http://requirejs.org/docs/optimization.html