Learn R Programming

jsutils (version 0.2.0)

terser: Minify JavaScript code using Terser

Description

Uses the Terser JavaScript library to minify JavaScript code. Note that the first time this function is called, it will load the terser library into the JavaScript context, which may take a few seconds. Subsequent calls will be faster.

Usage

terser(input, options = NULL)

Value

A list containing the minified code and any warnings or errors.

Arguments

input

Either a path to a file or a character string containing the JavaScript code to be minified.

options

A list of options to pass to Terser for minification. See the Terser documentation for available options.

Examples

Run this code
js_code <- "function add(a, b) { return a + b; }"
terser(js_code, list(sourceMap = TRUE))

Run the code above in your browser using DataLab