mateu-aguilo-bosch/js_defer — pull request #7 by robcolburn (2014-07-25 22:48:19+00:00)
Title: Rekey deferred files for aggregation

Say you have fancy logic to replace all of your JS files with `min.js` versions.
```php
foreach ($files as $file)
$file['data'] = str_replace('.js', '.min.js', file['data']);
```

Your original sources as keys and the modified buried in the array :thumsup:.
However, js_defer won't currently respect that when aggregation is turned on :cry:.

`drupal_build_js_cache()` won't use 'data' for getting contents (it does for hash name though).
```
foreach ($files as $path => $info) {
if ($info['preprocess']) {
// Append a ';' and a newline after each JS file to prevent them from running together.
$contents .= file_get_contents($path) . ";\n";
}
}
```

How are other popular 'min.js' variants picked up?

`drupal_get_js` knows this quirk and rekeys the array in advance :see_no_evil:
```
$key = 'aggregate_' . $item['group'] . '_' . $item['every_page'] . '_' . $index;
$processed[$key] = '';
$files[$key][$item['data']] = $item;
```