Skip to content
This repository

Minify output in css and javascript code #2069

Merged
merged 1 commit into from over 1 year ago

3 participants

Will Mendes Mirza Delic Andrey Andreev
Will Mendes

Minify output in css and javascript code

Will Mendes Minify output in css and javascript code
Minify output in css and javascript code
11dc139
Mirza Delic

Is this reliable code ?

Will Mendes

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

Andrey Andreev narfbg merged commit 6a53709 into from December 17, 2012
Andrey Andreev narfbg closed this December 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 14, 2012
Will Mendes Minify output in css and javascript code
Minify output in css and javascript code
11dc139
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. 10  system/core/Output.php
10  system/core/Output.php
@@ -693,6 +693,7 @@ public function minify($output, $type = 'text/html')
693 693
 			break;
694 694
 
695 695
 			case 'text/css':
  696
+			case 'text/javascript':
696 697
 
697 698
 				//Remove CSS comments
698 699
 				$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output);
@@ -701,11 +702,12 @@ public function minify($output, $type = 'text/html')
701 702
 				// semi-colons, parenthesis, commas
702 703
 				$output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!', '$1', $output);
703 704
 
704  
-			break;
  705
+				// Remove spaces
  706
+			        $output =  preg_replace('/  /s', ' ', $output);
705 707
 
706  
-			case 'text/javascript':
  708
+			        // Remove breaklines and tabs
  709
+			        $output =  preg_replace('/[\r\n\t]/', '', $output);
707 710
 
708  
-				// Currently leaves JavaScript untouched.
709 711
 			break;
710 712
 
711 713
 			default: break;
@@ -717,4 +719,4 @@ public function minify($output, $type = 'text/html')
717 719
 }
718 720
 
719 721
 /* End of file Output.php */
720  
-/* Location: ./system/core/Output.php */
  722
+/* Location: ./system/core/Output.php */
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.