Minification of JS without a plug-in

On occasions where plug-ins such as WP Rocket cause issues when using minification, then a simple minification can be added in functions.php while being disabled in the plug-in.

// MINIFICATION ON JS WITHOUT PLUGIN

function minimizeJavascriptSimple($javascript)
{
    return preg_replace(
        ["/\s+\n/", "/\n\s+/", "/ +/"],
        ["\n", "\n ", " "],
        $javascript
    );
}