tedious/JShrink

Use of ob_start()

optimalisatie opened this issue · 1 comments

Hi!

We would like to include JShrink in our Javascript Optimization plugin for WordPress however it is currently impossible because JShrink is based on ob_start.

Most websites apply minification of assets based on a output buffer that for example extracts scripts from the HTML. It is impossible to start a new output buffer within the callback of an output buffer so this is likely an issue that prevents usage for many applications.

We hereby want to suggest to change the output buffer concept.

It would be really nice if this could be fixed. Personally I use ob_start in my own code to use JShrink, so my code looks something like this:

function minifyJavascript(string $code): string{
    return \JShrink\Minifier::minify($code);
}
ob_start("minifyJavascript");

Since JShrink already uses ob_start internally, this causes problems and my above code doesn't work. It would be nice if you could fix this.