Minify output in css and javascript code #2069

Merged
merged 1 commit into from Dec 17, 2012
View
10 system/core/Output.php
@@ -693,6 +693,7 @@ public function minify($output, $type = 'text/html')
break;
case 'text/css':
+ case 'text/javascript':
//Remove CSS comments
$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output);
@@ -701,11 +702,12 @@ public function minify($output, $type = 'text/html')
// semi-colons, parenthesis, commas
$output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!', '$1', $output);
- break;
+ // Remove spaces
+ $output = preg_replace('/ /s', ' ', $output);
- case 'text/javascript':
+ // Remove breaklines and tabs
+ $output = preg_replace('/[\r\n\t]/', '', $output);
- // Currently leaves JavaScript untouched.
break;
default: break;
@@ -717,4 +719,4 @@ public function minify($output, $type = 'text/html')
}
/* End of file Output.php */
-/* Location: ./system/core/Output.php */
+/* Location: ./system/core/Output.php */