wikimedia/minify
Minification of JavaScript code and CSS stylesheets
Wikimedia\Minify\JavaScriptMinifier Class Reference

JavaScript Minifier. More...

Static Public Member Functions

static minify ( $s)
 Returns minified JavaScript code. More...
 
static parseError ( $fullJavascript, $position, $errorMsg)
 

Detailed Description

JavaScript Minifier.

This class is meant to safely minify JavaScript code, while leaving syntactically correct programs intact. Other libraries, such as JSMin require a certain coding style to work correctly. OTOH, libraries like jsminplus, that do parse the code correctly are rather slow, because they construct a complete parse tree before outputting the code minified. So this class is meant to allow arbitrary (but syntactically correct) input, while being fast enough to be used for on-the-fly minifying.

This class was written with ECMA-262 Edition 6 in mind ("ECMAScript 6"). Parsing features new to later editions of ECMAScript might not be supported. It's assumed that the input is syntactically correct; if it's not, this class may not detect that, and may produce incorrect output.

See https://262.ecma-international.org/6.0/.

Member Function Documentation

◆ minify()

static Wikimedia\Minify\JavaScriptMinifier::minify (   $s)
static

Returns minified JavaScript code.

Parameters
string$sJavaScript code to minify
Returns
string|bool Minified code or false on failure

◆ parseError()

static Wikimedia\Minify\JavaScriptMinifier::parseError (   $fullJavascript,
  $position,
  $errorMsg 
)
static
Parameters
string$fullJavascript
int$position
string$errorMsg
Returns
bool

The documentation for this class was generated from the following file: