You are here

protected function Minifier::initialize in Advanced CSS/JS Aggregation 8.4

Same name and namespace in other branches
  1. 8.2 advagg_js_minify/jshrink.inc \JShrink\Minifier::initialize()
  2. 8.3 advagg_js_minify/jshrink.inc \JShrink\Minifier::initialize()
  3. 7.2 advagg_js_compress/jshrink.inc \JShrink\Minifier::initialize()

Initializes internal variables, normalizes new lines,

Parameters

string $js The raw javascript to be minified:

array $options Various runtime options in an associative array:

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

File

advagg_js_minify/jshrink.inc, line 196

Class

Minifier
Minifier

Namespace

JShrink

Code

protected function initialize($js, $options) {
  $this->options = array_merge(static::$defaultOptions, $options);
  $js = str_replace("\r\n", "\n", $js);
  $js = str_replace('/**/', '', $js);
  $this->input = str_replace("\r", "\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;

  // Populate "a" with a new line, "b" with the first character, before
  // entering the loop
  $this->a = "\n";
  $this->b = $this
    ->getReal();
}