UIZE JavaScript Framework

MODULES Uize.Build.Scruncher

1. Introduction

The Uize.Build.Scruncher package provides a method for scrunching (compressing / minifying) JavaScript source code into compact / obfuscated scrunched code.

DEVELOPERS: Chris van Rensburg

1.1. Examples

The following example pages are good showcases for the Uize.Build.Scruncher module...

JavaScript Scruncher - Take bloated JavaScript source code and scrunch (minify, compress) it using this versatile tool. Drastically reduce its size and even obfuscate it!


Use the link below to search for example pages on the UIZE Web site that reference the Uize.Build.Scruncher module...


1.2. Implementation Info

The Uize.Build.Scruncher module defines the Uize.Build.Scruncher package under the Uize.Build namespace.

1.2.1. Features Introduced in This Module

The features listed in this section have been introduced in this module.




Uize.Build.Scruncher.moduleName | Uize.Build.Scruncher.pathToResources

1.2.2. Features Overridden in This Module

No features have been overridden in this module.

1.2.3. Features Inherited From Other Modules

This module has no inherited features.

1.2.4. Modules Directly Under This Namespace

There are no modules directly under this namespace.

1.2.5. Unit Tests

There is no dedicated unit tests module for the Uize.Build.Scruncher module.

2. Static Methods

2.1. Uize.Build.Scruncher.scrunch

Scrunches the specified source code string and returns an object, containing a string property for the scrunched form of the code, a string property with a report summarizing the savings from scrunching the code, and an array property containing all the comments from the source.


scruncherResultOBJ = Uize.Build.Scruncher.scrunch (sourceCodeSTR);

The returned object has the following composition...

  scrunchedCode:scrunchedCodeSTR, // the scrunched form of the code
  report:reportSTR,               // a multi-line summary of size savings
  comments:commentsARRAY          // an array of strings

The multi-line report contained in the report string property summarizes the file size savings from removed whitespace, removed comments, removed linebreaks, and scrunched identifiers. The comments array specified by the comments property can be used in the generation of comment-based documentation, as is done by the Uize.Doc.Sucker package.


scruncherResultOBJ = Uize.Build.Scruncher.scrunch (sourceCodeSTR,scruncherSettingsSTR);

When the optional scruncherSettingsSTR parameter is specified, the specified Scruncher settings string will be parsed and applied to the scrunching process. This is done after the Scruncher settings have been initialized and before any of the specified source file has been parsed, so before any Scruncher settings inside the source code are encountered. Therefore, Scruncher settings inside the code being scrunched will take precedence and will override any Scruncher settings specified in the scruncherSettingsSTR parameter.

The value of the scruncherSettingsSTR parameter should have the following syntax...

[setting0Name]="[setting0Value]" [settingNName]="[settingNValue]"

This parameter is useful for providing initial values for Scruncher settings that may not be specified inside a file (or files) being scrunched, and is particularly useful when using the Scruncher in build scripts.


var scruncherResult = Uize.Build.Scruncher.scrunch (sourceCode,'KeepHeadComment="FALSE"');

In the above example, the scruncherSettingsSTR parameter is being used to direct the Scruncher to omit the source code's head comment when scrunching it.


this feature was introduced in this module

3. Static Properties

3.1. Uize.Build.Scruncher.moduleName


this feature was introduced in this module

3.2. Uize.Build.Scruncher.pathToResources


this feature was introduced in this module