Skip to content

Optimizing concatenating files for curl.js

unscriptable edited this page Nov 28, 2011 · 8 revisions

Optimizing / concatenating files for curl.js

Even though curl.js is ultra-fast at asynchronously downloading modules and resources in parallel, it still works best when those modules and resources are bundled together into a small set of files. (Whether "small set" means "one file" or "half a dozen" depends entirely on your application and your environment.)

cram.js

curl.js has a companion project, cram.js. At its core, cram.js is a simple dependency walker. You feed it a "root module" (which could be your app's "main" module) and it walks the dependency tree, collects all modules and resources, and concatenates them into one file.

cram.js is still under development. We use it very successfully in a few projects already, but it is still at least one rev away from being production-worthy, imho. In the mean time, please consider using James Burke's r.js (see below).

If you want to start using cram.js now, please use the dev branch here.

r.js

curl.js can load optimized files built with r.js, the optimizer for RequireJS. Please note, however, that the AMD spec is still not solidified with regards to optimizing plugin-based resources. cram.js and r.js use different approaches to working with plugins. This means that you must use RequireJs's plugins -- not curl.js's plugins -- when using r.js.

## ### 1.

Clone this wiki locally