Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Well, if you go head-on, then your specific task is solved by devilo.us/
But you yourself understand that there can be many examples, you always need to test.
Try this:
function minifyCSS($string)
{
/* Strips Comments */
$string = preg_replace('!/\*.*?\*/!s','', $string);
$string = preg_replace('/\n\s*\n/',"\n", $string);
/* Minifies */
$string = preg_replace('/[\n\r \t]/',' ', $string);
$string = preg_replace('/ +/',' ', $string);
$string = preg_replace('/ ?([,:;{}]) ?/','$1',$string);
/* Kill Trailing Semicolon, Contributed by Oliver */
$string = preg_replace('/;}/','}',$string);
/* Return Minified CSS */
return $string;
}
csso Before
: Now
.test0 {
margin: 0
}
.test1 {
border: none
}
.test2 {
border: none
}
.test0 {
padding: 0
}
:
.test0 {
margin: 0
}
.test1, .test2 {
border: none
}
.test0 {
padding: 0
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question