I am using my own simple custom theme (with the default regions). One change I made was to put $scripts just above the $closure to ensure that all JS was not in the header.

From what I can tell, the minifying option of this module will only work if the JS files are located in the footer of the page.
(from javascript_aggregator.module)

function phptemplate_closure($main = 0) {
  $footer = module_invoke_all('footer', $main);
  
  $js_footer = drupal_get_js('footer');
  // Only do this for pages that have JavaScript on them.
  if (!empty($js_footer)) {
    $js_footer = _javascript_aggregator_minify($js_footer);
  }

  return implode("\n", $footer) . $js_footer;
}

Even though my JS not in the header (it's just before the closure) it is not being minified. I am guessing this is because most modules assign JS to the default $scope which is 'header'.

In order to get around this, I made the following change to the module, and now it works perfectly with my sites:

function phptemplate_closure($main = 0) {
..
  
  $js_footer = drupal_get_js('header');
..
}

I feel that I am missing something with the usage of this module or I need to do something in my theme layer. Is there another way to get all of the JS in my pages into the 'footer' so that I do not need to hack the module?

Comments

kentr’s picture

Mine is getting minified in the header.

Are you using JSMin or JSMin+? Could this be your issue:
#617742: JSMin not working. Incorrect file permissions on jsmin.php?

srobert72’s picture

Subscribing. Same issue.

JavaScript files moved from header to bottom (before closure) aren't minified.

srobert72’s picture

@andrewsuth
Maybe you use Parallel module.
In this case see : #619112: Incompatibility with Javascript Aggregator

It was cause of my problem.

derjochenmeyer’s picture

Version: 6.x-1.3 » 6.x-1.x-dev
Status: Active » Fixed

Javascript Aggregator minifies JS in Header and Footer

Header:

/**
 * Implementation of hook_preprocess_hook().
 *
 * Minify the aggregated JavaScript file if JavaScript Optimization is turned on.
 */
function javascript_aggregator_preprocess_page(&$variables) {
  // Only do this for pages that have JavaScript on them.
  if (!empty($variables['scripts'])) {
    $variables['scripts'] = _javascript_aggregator_minify($variables['scripts']);
  }
}

Footer:

/**
 * Implementation of theme_closure().
 */
function phptemplate_closure($main = 0) {
  $footer = module_invoke_all('footer', $main);

  $js_footer = drupal_get_js('footer');
  // Only do this for pages that have JavaScript on them.
  if (!empty($js_footer)) {
    $js_footer = _javascript_aggregator_minify($js_footer);
  }

  return implode("\n", $footer) . $js_footer;
}

If it is related to Parallel Modul see:
#770374: Incompatible with Parallel module

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.