tags
* with corresponding ";
}, $inputString);
}
/**
* Processes an HTML string to inline all external JavaScript files by replacing ";
}, $inputString);
}
/**
* Minifies CSS content by removing comments, unnecessary whitespaces, semicolons, and optimizing other aspects of the stylesheet.
* Might be broken, currently disabled in the config
*
* @param string $css The original CSS content.
* @return string The minified CSS content.
*/
function minifyCss(string $css): string
{
// Remove comments
$css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
// Remove whitespace
$css = preg_replace('/\s+/', ' ', $css);
// Remove unnecessary semicolons
$css = str_replace(';}', '}', $css);
// Remove spaces around colons
$css = str_replace(': ', ':', $css);
// Remove spaces around commas
$css = str_replace(', ', ',', $css);
return trim($css);
}
/**
* Minifies JavaScript content by removing comments, unnecessary whitespaces, and optimizing spaces around operators.
* Might be broken, currently disabled in the config
*
* @param string $js The original JavaScript content.
* @return string The minified JavaScript content.
*/
function minifyJs(string $js): string
{
// Remove newlines and tabs
$js = str_replace("\t", '', $js);
// Remove spaces around operators
$js = preg_replace('~\s*([=+\-*/])\s*~', '$1', $js);
return trim($js);
}