My solution to minimize the css directly in the in the header:
<style>
<?php ob_start('minify');
function minify($buffer) {
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
$buffer = str_replace(array(' } ',' }','} ',';}'), '}', $buffer);
$buffer = str_replace(array(' { ',' {','{ '), '{', $buffer);
$buffer = str_replace(array(' : ',' :',': '), ':', $buffer);
return $buffer; }
include('assets/css/main.css');
if($page->template() != 'default'){
include('assets/css/templates/' . $page->template() . '.css');
}
ob_end_flush(); ?>
</style>
Gist / Github: https://gist.github.com/starckio/ac1da52b9512122b05933a551efef21c