Compactar CSS via PHP

<?php

$expires = 60*60*24; // how long to cache in secs..
header("Pragma: public");
header("Cache-Control: maxage=".$expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
header('Content-type: text/css');
ob_start("compress");

function compress($minify) {
$a = array('; ', ' }', '{ ', '\r\n', '\r', '\n', '\t', ' ',' ',' ');
$b = array(';', '}', '{', '', '', '', '', '', '', '');
return str_replace($a, $b,preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!','',$minify));
}

/* css files for combining */
include('recursos/css/style.min.css');

ob_end_flush();

 

Comentários

Postagens mais visitadas deste blog

Api para correspondente bancário - Analise Info