A super easy PHP Framework for web development! https://github.com/exacti/phacil-framework

15 lines
418 B

<?php
/**
* @param mixed $css
* @return string[]|string|null
*/
function minimizeCSS($css){
$css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
$css = preg_replace('/\/\*((?!\*\/).)*\*\//', '', $css); // negative look ahead
$css = preg_replace('/\s{2,}/', ' ', $css);
$css = preg_replace('/\s*([:;{}])\s*/', '$1', $css);
$css = preg_replace('/;}/', '}', $css);
return $css;
}