uglify: Compress and Reformat JavaScript Code

Description Usage Arguments References Examples

Description

UglifyJS is a JavaScript compressor/minifier written in JavaScript. It also contains tools that allow one to automate working with JavaScript code.

Usage

1
2
3
4
5

Arguments

text

a character vector with JavaScript code

beautify

prettify (instead of minify) code

files

a character vector of filenames

...

additional arguments for the optimizer or generator.

References

UglifyJS2 Documentation: http://lisperator.net/uglifyjs/.

Examples

1
2
3
code <- "function test(x, y){ x = x || 1; y = y || 1; return x*y;}"
cat(uglify_optimize(code))
cat(uglify_reformat(code, beautify = TRUE, indent_level = 2))

Example output

function test(x,y){return x=x||1,y=y||1,x*y}function test(x, y) {
  x = x || 1;
  y = y || 1;
  return x * y;
}

js documentation built on July 2, 2020, 2:47 a.m.