Skip to content

Commit

Permalink
Minify output in css and javascript code
Browse files Browse the repository at this point in the history
Minify output in css and javascript code
  • Loading branch information
willmendesneto committed Dec 14, 2012
1 parent a64c4fb commit 11dc139
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions system/core/Output.php
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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 */

0 comments on commit 11dc139

Please sign in to comment.