Skip to content
tlrobinson edited this page Aug 12, 2010 · 3 revisions

“press” Tool

A tool to analyze and strip unused files from a Cappuccino project’s .sj bundles.

Overview

The “press” tool takes a complete Cappuccino application, including frameworks, and attempts to remove unused code. You should typically run press after compiling and bundling your application code through jake.

In a default application “press” is able to reduce the size of the code delivered to the client by approximately 30%. Combined with enabling Gzip encoding on your webserver you can significantly reduce the size and thus load time of your application.

“press” works by loading the application in a command-line JavaScript environment, and recording the classes and other global variables defined by each file. It then analyzes the dependency graph of imports and global variable references, retaining only those files which are used.

Future versions of “press” may attempt even more agressive code stripping, at the class or method level.

Note: The “—flatten” option available in previous versions of “press” has been moved to it’s own tool, flatten.

Note: The JavaScript environment the application is loaded in does not support the full DOM API available in the browser, so you should be careful not to use such APIs in the top level of your code files. However the application is not executed (i.e. “main” and the subsequent “CPApplicationMain” functions are not called) so DOM code run during the normal course of the application is not executed.

Usage

Usage: press [OPTIONS] INPUT_PROJECT OUTPUT_PROJECT

Analyze and strip unused files from a Cappuccino project’s .sj bundles.

  • -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’])
  • -f --force: Force overwriting OUTPUT_PROJECT if it exists
  • -v --verbose: Verbose logging
  • -h --help: displays usage information (final option)