Best CSS and JS aggregation/minification strategy for D7
For D7, there's Core Library which has a learning mode that aggregates based on real-world statistics about your site.

If you want to brute-force everything into one giant aggregate, I've written an article with some sample code:

/**
 * Implements hook_js_alter().
 */
function mymodule_js_alter(&amp;$javascript) {
  uasort($javascript, 'drupal_sort_css_js');
  $i = 0;
  foreach ($javascript as $name =&gt; $script) {
    $javascript[$name]['weight'] = $i++;
    $javascript[$name]['group'] = JS_DEFAULT;
    $javascript[$name]['every_page'] = FALSE;
  }
}

/**
 * Implements hook_css_alter().
 */
function mymodule_css_alter(&amp;$css) {
  uasort($css, 'drupal_sort_css_js');
  $i = 0;
  foreach ($css as $name =&gt; $style) {
    $css[$name]['weight'] = $i++;
    $css[$name]['group'] = CSS_DEFAULT;
    $css[$name]['every_page'] = FALSE;
  }
}


Drupal.org issue #1034208 also proposes relaxing the strict ordering requirements slightly.