Field Summary |
|
final public static int | COMPRESS_REMOVE_NEWLINES Flag for use in javascript compression: Remove all lines endings.
Warning: Javascript can add semi-colons in for you. |
final public static int | COMPRESS_SHRINK_VARS Flag for use in javascript compression: Shrink variable names. |
final public static int | COMPRESS_STRIP_BLANKLINES Flag for use in javascript compression: Remove blank lines. |
final public static int | COMPRESS_STRIP_ML_COMMENTS Flag for use in javascript compression: Remove multi line comments. |
final public static int | COMPRESS_STRIP_SL_COMMENTS Flag for use in javascript compression: Remove single line comments. |
final public static int | COMPRESS_TRIM_LINES Flag for use in javascript compression: Remove whitespace at the start and end of a line. |
final public static int | LEVEL_DEBUGGABLE Basic compression that leaves the source fully debuggable. |
final public static int | LEVEL_NONE Compression level that leaves the source un-touched. |
final public static int | LEVEL_NORMAL Normal compression makes all changes that will work for generic javascript. |
final public static int | LEVEL_ULTRA LEVEL_ULTRA performs additional compression that makes some assumptions about the
style of javascript. |
protected int | compressionLevel |
Method Summary |
|
public static String | compress(String text, int level) Compress the source code by removing java style comments and removing
leading and trailing spaces.
Parameters: text - The javascript (or java) program to compress Parameters: level - The compression level - see LEVEL_* and COMPRESS_* constants. |
public String | compressJavaScript(String script) |
public void | setCompressionLevel(int compressionLevel) |
public static String | shrinkVariableNames(String text) Shrink variable names to a minimum.
Parameters: text - The javascript program to shrink the variable names in. |
public static String | stripBlankLines(String text) Remove all blank lines from a string. |
public static String | stripMultiLineComments(String text) |
public static String | stripNewlines(String text) Remove all newline characters from a string. |
public static String | stripSingleLineComments(String text) |
public static String | trimLines(String text) Remove any leading or trailing spaces from a line of code.
This function could be improved by making it strip unnecessary double
spaces, but since we would need to leave double spaces inside strings
this is not simple and since the benefit is small, we'll leave it for now
Parameters: text - The javascript program to strip spaces from. |