Skip to content

Commit 53098cf

Browse files
committed
Add hook_js_cache_alter().
1 parent 9183853 commit 53098cf

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

includes/common.inc

+4
Original file line numberDiff line numberDiff line change
@@ -4929,6 +4929,10 @@ function drupal_build_js_cache($files) {
49294929
$contents .= file_get_contents($path) . ";\n";
49304930
}
49314931
}
4932+
4933+
// Allow modules to act on the js_cche before writing to disk.
4934+
drupal_alter('js_cache', $contents);
4935+
49324936
// Prefix filename to prevent blocking by firewalls which reject files
49334937
// starting with "ad*".
49344938
$filename = 'js_' . drupal_hash_base64($contents) . '.js';

modules/system/system.api.php

+20
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,26 @@ function hook_js_alter(&$javascript) {
744744
$javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
745745
}
746746

747+
/**
748+
* Perform necessary alterations to the concatenated JavaScript before it is
749+
* presented on the page.
750+
*
751+
* @param $contents
752+
* A string of the concatenated JavaScript.
753+
*
754+
* @see drupal_build_js_cache()
755+
*/
756+
function hook_js_cache_alter(&$contents) {
757+
$header = <<<HEADER
758+
/**
759+
* Powered by Pressflow
760+
* http://pressflow.org
761+
*/
762+
HEADER;
763+
764+
$contents = $header . "\n" . $contents;
765+
}
766+
747767
/**
748768
* Registers JavaScript/CSS libraries associated with a module.
749769
*

0 commit comments

Comments
 (0)