Same name in other branches
- 5.0.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_basicCompression()
- 6.0.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_basicCompression()
- 7.x-2.x advagg_js_compress/jspacker.inc \JavaScriptPacker::_basicCompression()
- 8.x-2.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_basicCompression()
- 8.x-3.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_basicCompression()
- 8.x-4.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_basicCompression()
Fichier
-
advagg_js_compress/
jspacker.inc, line 124
Classe
Code
private function _basicCompression($script) {
$parser = new ParseMaster();
// make safe
$parser->escapeChar = '\\';
// protect strings
$parser->add('/\'[^\'\\n\\r]*\'/', self::IGNORE);
$parser->add('/"[^"\\n\\r]*"/', self::IGNORE);
// remove comments
$parser->add('/\\/\\/[^\\n\\r]*[\\n\\r]/', ' ');
$parser->add('/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\//', ' ');
// protect regular expressions
$parser->add('/\\s+(\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?)/', '$2');
// IGNORE
$parser->add('/[^\\w\\x24\\/\'"*)\\?:]\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?/', self::IGNORE);
// remove: ;;; doSomething();
if ($this->_specialChars) {
$parser->add('/;;;[^\\n\\r]+[\\n\\r]/');
}
// remove redundant semi-colons
$parser->add('/\\(;;\\)/', self::IGNORE);
// protect for (;;) loops
$parser->add('/;+\\s*([};])/', '$2');
// apply the above
$script = $parser->exec($script);
// remove white-space
$parser->add('/(\\b|\\x24)\\s+(\\b|\\x24)/', '$2 $3');
$parser->add('/([+\\-])\\s+([+\\-])/', '$2 $3');
$parser->add('/\\s+/', '');
// done
return $parser->exec($script);
}