diff --git a/includes/ajax.inc b/includes/ajax.inc
index 05416af..ad50c28 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.
@@ -588,9 +591,16 @@ function ctools_ajax_associate_url_to_element(&$form, &$form_element, $dest, $ty
 }
 
 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 +617,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.
