Same name in other branches
- 5.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::loop()
- 6.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::loop()
- 7.x-2.x advagg_js_compress/jshrink.inc \JShrink\Minifier::loop()
- 8.x-2.x advagg_js_minify/jshrink.inc \JShrink\Minifier::loop()
- 8.x-3.x advagg_js_minify/jshrink.inc \JShrink\Minifier::loop()
The primary action occurs here. This function loops through the input string, outputting anything that's relevant and discarding anything that is not.
1 call to Minifier::loop()
- 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 218
Class
- Minifier
- Minifier
Namespace
JShrinkCode
protected function loop() {
while ($this->a !== false && !is_null($this->a) && $this->a !== '') {
switch ($this->a) {
// new lines
case "\n":
// if the next line is something that can't stand alone preserve the newline
if ($this->b !== false && strpos('(-+{[@', $this->b) !== false) {
echo $this->a;
$this->saveString();
break;
}
// if B is a space we skip the rest of the switch block and go down to the
// string/regex check below, resetting $this->b with getReal
if ($this->b === ' ') {
break;
}
// otherwise we treat the newline like a space
case ' ':
if (static::isAlphaNumeric($this->b)) {
echo $this->a;
}
$this->saveString();
break;
default:
switch ($this->b) {
case "\n":
if (strpos('}])+-"\'', $this->a) !== false) {
echo $this->a;
$this->saveString();
break;
}
else {
if (static::isAlphaNumeric($this->a)) {
echo $this->a;
$this->saveString();
}
}
break;
case ' ':
if (!static::isAlphaNumeric($this->a)) {
break;
}
default:
// check for some regex that breaks stuff
if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) {
$this->saveRegex();
continue 3;
}
echo $this->a;
$this->saveString();
break;
}
}
// do reg check of doom
$this->b = $this->getReal();
if ($this->b == '/' && strpos('(,=:[!&|?', $this->a) !== false) {
$this->saveRegex();
}
}
}