Same name in other branches
  1. 5.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::initialize()
  2. 7.x-2.x advagg_js_compress/jshrink.inc \JShrink\Minifier::initialize()
  3. 8.x-2.x advagg_js_minify/jshrink.inc \JShrink\Minifier::initialize()
  4. 8.x-3.x advagg_js_minify/jshrink.inc \JShrink\Minifier::initialize()
  5. 8.x-4.x advagg_js_minify/jshrink.inc \JShrink\Minifier::initialize()

Initializes internal variables, normalizes new lines,

Paramètres

string $js The raw javascript to be minified:

array $options Various runtime options in an associative array:

1 call to Minifier::initialize()
Minifier::minifyDirectToOutput dans advagg_js_minify/jshrink.inc
Processes a javascript string and outputs only the required characters, stripping out all unneeded characters.

Fichier

advagg_js_minify/jshrink.inc, line 206

Classe

Minifier
Minifier

Namespace

JShrink

Code

protected function initialize($js, $options) {
    $this->options = array_merge(static::$defaultOptions, $options);
    $this->input = str_replace([
        "\r\n",
        '/**/',
        "\r",
    ], [
        "\n",
        "",
        "\n",
    ], $js);
    // We add a newline to the end of the script to make it easier to deal
    // with comments at the bottom of the script- this prevents the unclosed
    // comment error that can otherwise occur.
    $this->input .= PHP_EOL;
    // save input length to skip calculation every time
    $this->len = strlen($this->input);
    // Populate "a" with a new line, "b" with the first character, before
    // entering the loop
    $this->a = "\n";
    $this->b = $this->getReal();
}