dean.edwards.name/packer/2/usage/

Usage

All statements, including function declarations, must be correctly terminated with semi-colons. View the sample code.

Options

Encoding

Sets the compression/obfuscation level:

None

Basic compression only. White space and comments are removed, special characters are encoded.

Numeric (Base 10)

All words are encoded to a numeric value.

Normal (Base 62)

Words are encoded to an alphanumeric value. This is the recommended setting. The other settings (apart from "None") are available for interest more than anything else.

High ASCII (Base 95)

This produces slightly higher compression.

If you use the high ASCII encoding then the packed script should be served with an encoding of ISO-8859-1. Because of a bug in Internet Explorer (I’m always writing this), the containing page should be served with the same encoding. If you are not sure what this means then use the "Normal" setting.

Fast Decode

Inserts a small (120 bytes) routine into the unpacker to speed up decoding (recommended).

Special Characters

To aid compression you may flag your private and local variables. The packer will then encode your variables as shown below. Because there is no real concept of "private" and "local" variables in JavaScript I’ll define the terms as follows:

Local ($)

Variables used only in the current scope. Typically, arguments and variables in functions. Flag local variables with a dollar sign ($) prefix and they will be truncated to the first character. Additional dollar signs will lengthen the result. Numeric suffixes are preserved.

Example:

// unpacked:
function test($left, $top1, $top2, $$length) {
	// do something
};
// packed:
function test(l,t1,t2,le){};

Take care not to create naming conflicts in your functions. Restrict the dollar sign truncation to local variables only.

Private (_)

Variables used throughout your script but not outside of it. Flag private variables with a single underscore (_) prefix and they will be encoded to an underscore followed by a number.

An example:

// unpacked:
var _CONSTANT = 42;
function _test($left, $top1, $top2, $$length) {
	return ($top1 / $top2) + _CONSTANT;
};
// packed:
var _0=42;function _1(l,t1,t2,le){return(t1/t2)+_0};
Debug Code (;;;)

Three semi-colons (;;;) are treated like single-line comments.

For example, this code:

;;; alert("TEST!");

Would be removed by the packing program.

Platforms

Packed scripts should successfully unpack on all browsers that support JavaScript. Only basic JavaScript functionality is used to decode the packed script.

Some browsers may not support the packer itself. The web interface requires DOM support. Legacy browsers will display a disabled interface.