diff --git a/css.php b/css.php index 05be66e..4fbd1f4 100644 --- a/css.php +++ b/css.php @@ -11,11 +11,29 @@ $this_file = 'css.php'; //Function for compressing the CSS as tightly as possible function compress($buffer) { + //Remove CSS comments $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); + //Remove tabs, spaces, newlines, etc. - $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); $buffer = preg_replace('`\s+`', ' ', $buffer); + $replace = array( + ' )' => ')', + ') ' => ')', + ' }' => '}', + '} ' => '}', + ' {' => '{', + '{ ' => '{', + ', ' => ',', + ': ' => ':', + '; ' => ';', + ); + + //Eradicate every last space! + $buffer = trim(strtr($buffer, $replace)); + $buffer = str_replace('{ ', '{', $buffer); + $buffer = str_replace('} ', '}', $buffer); + return $buffer; } diff --git a/js.php b/js.php index aaff9ec..c58ab24 100644 --- a/js.php +++ b/js.php @@ -15,7 +15,7 @@ $this_file = 'js.php'; /** * Get Files * - * Concatonates the javascript files for the current + * Concatenates the javascript files for the current * group as a string * @return string */ @@ -133,7 +133,7 @@ else //making file size smaller and transfer rate quicker ob_start("ob_gzhandler"); -header("Content-Type: application/x-javascript; charset=utf8"); +header("Content-Type: application/javascript; charset=utf8"); header("Cache-control: public, max-age=691200, must-revalidate"); header("Last-Modified: ".gmdate('D, d M Y H:i:s', $last_modified)." GMT"); header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime($this_file) + 691200))." GMT");