Index: javascript_aggregator.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/javascript_aggregator/javascript_aggregator.module,v
retrieving revision 1.5
diff -u -r1.5 javascript_aggregator.module
--- javascript_aggregator.module	18 Jan 2008 16:58:22 -0000	1.5
+++ javascript_aggregator.module	18 Jan 2008 19:15:05 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: javascript_aggregator.module,v 1.5 2008/01/18 16:58:22 derjochenmeyer Exp $
+// $Id: javascript_aggregator.module,v 1.4 2008/01/18 16:52:18 derjochenmeyer Exp $
 
 /**
  * @file
@@ -32,15 +32,25 @@
 
     foreach ($scripts_js_files as $scripts_js_file) {
       // read contents of js file and add it to $contents
-      $contents .= file_get_contents(preg_replace('/^\//', '', $scripts_js_file));
+      $data = file_get_contents(preg_replace('/^\//', '', $scripts_js_file));
+
+      if (variable_get('optimize_js', 0)) {
+        // Perform some safe JS optimizations.
+        $data = preg_replace('<
+          /\*([^*\\\\]|\*(?!/))+\*/    # Remove comments
+          >x', '\1', $data);                                 
+      }
+      
+      $contents .= $data;
+
       // Add a semicolon to the end of each file to make sure every line has an end
-      $contents .= "\n\n;\n\n";
+      // $contents .= "\n;\n";
     }
     
     // Create the js file.
     file_save_data($contents, $jsfile, FILE_EXISTS_REPLACE);
   }
-
+  
   if (variable_get('aggregate_js', 0)) {
     // remove aggregated js files from $scripts using the same $pattern
     $scripts  = preg_replace($pattern, "",$scripts);
@@ -66,7 +76,6 @@
   drupal_goto('admin/settings/performance');
 }
 
-
 /**
  * Implementation of hook_form_alter.
  *
@@ -93,11 +102,19 @@
       '#options' => array(t('Disabled'), t('Enabled')),
       '#description' => t("This option can interfere with module development. It is recommended to only turn this on when your site is complete."),
     );
+    
+    $form['javascript_aggregation']['optimize_js'] = array(
+      '#type' => 'radios',
+      '#title' => t('Optimize JavaScript files'),
+      '#default_value' => variable_get('optimize_js', 0),
+      '#disabled' => !$is_writable,
+      '#options' => array(t('Disabled'), t('Enabled')),
+      '#description' => t("This option removes /* */ comments."),
+    );
 
   }
 }
 
-
 /**
  * Implementation of hook_menu.
  *
