Permalink
Browse files

Add hook_js_cache_alter().

  • Loading branch information...
elliotttf committed Feb 21, 2013
1 parent 9183853 commit 53098cf059236110716ca97c18565a178c458b43
Showing with 24 additions and 0 deletions.
  1. +4 −0 includes/common.inc
  2. +20 −0 modules/system/system.api.php
View
@@ -4929,6 +4929,10 @@ function drupal_build_js_cache($files) {
$contents .= file_get_contents($path) . ";\n";
}
}
+
+ // Allow modules to act on the js_cche before writing to disk.
+ drupal_alter('js_cache', $contents);
+
// Prefix filename to prevent blocking by firewalls which reject files
// starting with "ad*".
$filename = 'js_' . drupal_hash_base64($contents) . '.js';
@@ -744,6 +744,26 @@ function hook_js_alter(&$javascript) {
$javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
}
+/**
+ * Perform necessary alterations to the concatenated JavaScript before it is
+ * presented on the page.
+ *
+ * @param $contents
+ * A string of the concatenated JavaScript.
+ *
+ * @see drupal_build_js_cache()
+ */
+function hook_js_cache_alter(&$contents) {
+ $header = <<<HEADER
+/**
+ * Powered by Pressflow
+ * http://pressflow.org
+ */
+HEADER;
+
+ $contents = $header . "\n" . $contents;
+}
+
/**
* Registers JavaScript/CSS libraries associated with a module.
*

0 comments on commit 53098cf

Please sign in to comment.