Permalink
Browse files

Merge pull request #2069 from willmendesneto/develop

Minify output in css and javascript code
  • Loading branch information...
2 parents 3bc548e + 11dc139 commit 6a53709e448bd6fd2603ede85ddd34b3388ec11f @narfbg narfbg committed Dec 17, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 system/core/Output.php
View
@@ -780,6 +780,7 @@ public function minify($output, $type = 'text/html')
break;
case 'text/css':
+ case 'text/javascript':
//Remove CSS comments
$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output);
@@ -788,11 +789,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;
@@ -804,4 +806,4 @@ public function minify($output, $type = 'text/html')
}
/* End of file Output.php */
-/* Location: ./system/core/Output.php */
+/* Location: ./system/core/Output.php */

0 comments on commit 6a53709

Please sign in to comment.