minify
minify copied to clipboard
Remove Multiline Comments using callback (postProcess)
Has anyone figured out a successful way of removing the remaining comments and multiline comments that remain after minification?
I know this is by design to keep the copyrights intact, but tools like GTmetrix consider the files not fully compressed and always suggest further reduction of file size by removing the comments and line breaks.
I've tried cleaning up the code via the postProcess() callback function, but all of the Regex masks that I try to use end up breaking my scripts.
Any help or direction would be greatly appreciated!
Nevermind. Ended up writing my own expression instead of using suggested ones and it works great. Here's the snippet if anyone needs it:
// Remove Comments
function postProcess($content, $type) {
$content = preg_replace('~\/\*\!.*?\*\/~s', "\n", $content);
$content = trim($content);
return $content;
}
$min_serveOptions['postprocessor'] = 'postProcess';
Hello. In which file and where to insert this code? I pasted into config.php but it doesn't work.