Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Minify output in css and javascript code #2069

Merged
merged 1 commit into from

3 participants

@willmendesneto

Minify output in css and javascript code

@willmendesneto willmendesneto Minify output in css and javascript code
Minify output in css and javascript code
11dc139
@mirzadelic

Is this reliable code ?

@willmendesneto

I use in my applications with no problems. I use in my applications with no problems.

@narfbg narfbg merged commit 6a53709 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 14, 2012
  1. @willmendesneto

    Minify output in css and javascript code

    willmendesneto authored
    Minify output in css and javascript code
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +6 −4 system/core/Output.php
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 */
Something went wrong with that request. Please try again.