meelash edited this page Aug 12, 2010 · 2 revisions

flatten Tool

“flatten” inlines all code into one or more JavaScript files, allowing cross-domain loading as well as eliminating dynamic evaluation (eval, etc)


The “flatten” tool inlines all preprocessed Objective-J code (plain old JavaScript) of an application into one or more script files, suitable for loading from a CDN or other cross-domain scenario.

Additionally, since all code is inlined “flatten” eliminates usage of the “new Function()” API which, like “eval()”, is sometimes restricted, for example in Adobe AIR.

Some people also find the load performance of a “flattened” application to be better, in particular when using the split option. Using the “—split N” argument will split the script file into N files, which allows the browser to download them in parallel. Browsers can typically download 2 to 6 files in parallels, so that would be a good range to try for the “—split” parameter.

“flatten” will typically be the last build tool used before deployment, after the compiling and bundling (jake step) and optionally press.


Combine a Cappuccino application into a single JavaScript file.

  • -m --main MAIN: The relative path (from INPUT_PROJECT) to the main file (default: ‘main.j’)
  • -F --framework FRAMEWORKS: Add a frameworks directory, relative to INPUT_PROJECT (default: [‘Frameworks’])
  • -P --path PATHS: Add a path (relative to the application root) to inline.
  • -f --force: Force overwriting OUTPUT_PROJECT if it exists
  • --index INDEX: The root HTML file to modify (default: index.html)
  • -s --split NUMBER: Split into multiple files
  • -c --compressor COMPRESSOR: Select a compressor to use (closure-compiler, yuicompressor, shrinksafe), or “none” (default: shrinksafe)
  • --manifest: Generate HTML5 cache manifest.
  • -v --verbose: Verbose logging
  • -h --help: displays usage information (final option)