diff --git a/includes/ajax.inc b/includes/ajax.inc
index 05416af..300b2b9 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -3,6 +3,9 @@
 // Set this so we can tell that the file has been included at some point.
 define('CTOOLS_AJAX_INCLUDED', 1);
 
+// Default value for running the ctools_ajax_page_preprocess() function.
+define('CTOOLS_AJAX_PAGE_PREPROCESS', 1);
+
 /**
  * @file
  * Utilize the CTools AJAX responder.
@@ -587,10 +590,54 @@ function ctools_ajax_associate_url_to_element(&$form, &$form_element, $dest, $ty
   );
 }
 
+/**
+ * Implement hook_advagg_js_header_footer_alter.
+ */
+function ctools_advagg_js_header_footer_alter(&$master_set, $preprocess_js, $public_downloads) {
+  global $_advagg;
+
+  // Get all JS files set to be loaded.
+  $js_files = array();
+  foreach ($master_set as $scope => $scripts) {
+    if (empty($scripts)) {
+      continue;
+    }
+    ctools_process_js_files($js_files, $scripts);
+  }
+
+  // Add list of CSS & JS files loaded to the settings in the footer.
+  $loaded = array('CToolsAJAX' => array('scripts' => $js_files, 'css' => $_advagg['ctools']['css_files']));
+  if (!isset($master_set['footer']['setting']) || !is_array($master_set['footer']['setting'])) {
+    $master_set['footer']['setting'] = array();
+  }
+  $master_set['footer']['setting'][] = $loaded;
+}
+
+/**
+ * Implement hook_advagg_css_pre_alter.
+ */
+function ctools_advagg_css_pre_alter(&$css, $preprocess_css, $public_downloads) {
+  global $_advagg;
+
+  // Get all CSS files set to be loaded.
+  $css_files = array();
+  ctools_process_css_files($css_files, $css);
+
+  // Save to the $_advagg global.
+  $_advagg['ctools']['css_files'] = $css_files;
+}
+
 function ctools_ajax_page_preprocess(&$variables) {
+  // See if we will be running this hook.
+  if (!variable_get('ctools_ajax_page_preprocess', CTOOLS_AJAX_PAGE_PREPROCESS)) {
+    return;
+  }
+
   $js_files = $css_files = array();
-  ctools_process_js_files($js_files, 'header');
-  ctools_process_js_files($js_files, 'footer');
+  $scripts = drupal_add_js(NULL, NULL, 'header');
+  ctools_process_js_files($js_files, $scripts);
+  $scripts = drupal_add_js(NULL, NULL, 'footer');
+  ctools_process_js_files($js_files, $scripts);
   ctools_process_css_files($css_files, $variables['css']);
 
   // Add loaded JS and CSS information to the footer, so that an AJAX
@@ -607,10 +654,9 @@ function ctools_ajax_page_preprocess(&$variables) {
 /**
  * Create a list of javascript files that are on the page.
  */
-function ctools_process_js_files(&$js_files, $scope) {
+function ctools_process_js_files(&$js_files, $scripts) {
   // Automatically extract any 'settings' added via drupal_add_js() and make
   // them the first command.
-  $scripts = drupal_add_js(NULL, NULL, $scope);
 
   // Get replacements that are going to be made by contrib modules and take
   // them into account so we don't double-load scripts.
