java.lang.Object
ro.isdc.wro.extensions.processor.support.uglify.UglifyJs

public class UglifyJs extends Object

The underlying implementation use untagged version (commited on 2012-09-08 14:15:12).

See the project on GitHub.

The uglify script is resulted from merging of the following two scripts: parse-js.js, process.js.

Since:
1.3.1
Author:
Alex Objelean
  • Field Details

    • DEFAULT_UGLIFY_JS

      public static final String DEFAULT_UGLIFY_JS
      The name of the uglify script to be used by default.
      See Also:
  • Constructor Details

    • UglifyJs

      public UglifyJs(UglifyJs.Type uglifyType)
      Parameters:
      uglifyType - Depending on the type, the code will either be uglified (compressed and minimized), or it will be beautified (nice formatted).
  • Method Details

    • uglifyJs

      public static UglifyJs uglifyJs()
      Factory method for creating the uglifyJs engine.
    • beautifyJs

      public static UglifyJs beautifyJs()
      Factory method for creating the beautifyJs engine.
    • setReservedNames

      public UglifyJs setReservedNames(String reservedNames)
      some libraries rely on certain names to be used, so this option allow you to exclude such names from the mangler. For example, to keep names require and $super intact you'd specify –reserved-names "require,$super".
      Parameters:
      reservedNames - the reservedNames to set
    • getScriptAsStream

      protected InputStream getScriptAsStream()
      Returns:
      the stream of the uglify script. Override this method to provide a different script version.
    • process

      public String process(String filename, String code) throws IOException
      Parameters:
      filename - js content to process.
      Returns:
      packed js content.
      Throws:
      IOException
    • createOptionsAsJson

      protected String createOptionsAsJson() throws IOException
      Reads by default options from options.js file located in the same package. This is an example of how the options could look like:
       {
          codegen_options: {
            beautify: false,
            space_colon: false
          },
          squeeze: true,
          dead_code: true,
          mangle: true
       }
       
      Returns:
      json representation of options.
      Throws:
      IOException