--- javascript_aggregator.module.orig	2011-02-24 11:55:19.000000000 +0100
+++ javascript_aggregator.module	2011-02-24 12:22:36.000000000 +0100
@@ -33,15 +33,23 @@
       '#title' => t('Do not auto generate .htaccess file (experts only)'),
       '#description' => t("If you want to use GZipping and your host doesn't like multiple .htaccess files check this option, together with the option above to bypass htaccess file generation and follow directions in the README.txt."),
       '#default_value' => variable_get('javascript_aggregator_no_htaccess', FALSE),
-      '#weight' => 5,
+      '#weight' => 6,
     );
     $form['bandwidth_optimizations']['javascript_aggregator_jsminplus'] = array(
       '#type' => 'checkbox',
       '#title' => t('Use JSMin+ instead of JSMin'),
       '#description' => t('Check this option to use <a href="@jsminplus">JSMin+</a> instead of JSMin.', array('@jsminplus' => 'http://crisp.tweakblogs.net/blog/1665/a-new-javascript-minifier-jsmin+.html')),
       '#default_value' => variable_get('javascript_aggregator_jsminplus', FALSE),
+      '#weight' => 5,
+    );
+    $form['bandwidth_optimizations']['javascript_aggregator_php_jsmin'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Use php_jsmin instead of JSMin'),
+      '#description' => t('Check this option to use <a href="@php_jsmin">php_jsmin</a> instead of JSMin.', array('@php_jsmin' => 'http://www.ypass.net/software/php_jsmin/')),
+      '#default_value' => variable_get('javascript_aggregator_php_jsmin', FALSE),
       '#weight' => 4,
     );
+
   }
 }
 
@@ -108,7 +116,11 @@
       // Create the JSMinified file if it doesn't exist yet.
       if (!file_exists($jsmin_file_path)) {
 
-        if (variable_get('javascript_aggregator_jsminplus', FALSE)) {
+        if (variable_get('javascript_aggregator_php_jsmin', FALSE) && function_exists('jsmin')) {
+          // jsmin the contents of the aggregated file.
+          $contents = jsmin(file_get_contents(file_directory_path() . $aggregated_file_name));
+        }
+        else if (variable_get('javascript_aggregator_jsminplus', FALSE)) {
           // JSMin+ the contents of the aggregated file.
           require_once(drupal_get_path('module', 'javascript_aggregator') .'/jsminplus.php');
           // Strip Byte Order Marks (BOM's) from the file, JSMin+ cannot parse these.