diff --git a/cdn.module b/cdn.module
index 601ac2c..c16952a 100644
--- a/cdn.module
+++ b/cdn.module
@@ -243,6 +243,54 @@ function cdn_element_info_alter(&$type) {
 }
 
 /**
+ * Implements hook_css_alter().
+ */
+function cdn_css_alter(&$css) {
+  if (!cdn_status_is_enabled()) {
+    return;
+  }
+
+  // Ensure that CDN-blacklisted CSS files are not aggregated, so that the CSS
+  // aggregates can still be served from the CDN.
+  foreach (array_keys($css) as $key) {
+    // Skip $type = 'inline'.
+    if (is_numeric($key)) {
+      continue;
+    }
+    // Handle $type = 'file' and 'external'.
+    elseif (!cdn_check_file($key)) {
+      $javascript[$key]['preprocess'] = FALSE;
+    }
+  }
+}
+
+/**
+ * Implements hook_js_alter().
+ */
+function cdn_js_alter(&$javascript) {
+  if (!cdn_status_is_enabled()) {
+    return;
+  }
+
+  // Ensure that CDN-blacklisted JS files are not aggregated, so that the JS
+  // aggregates can still be served from the CDN.
+  foreach (array_keys($javascript) as $key) {
+    // Skip $type = 'inline'.
+    if (is_numeric($key)) {
+      continue;
+    }
+    // Skip $type = 'setttings'.
+    elseif ($key === 'settings') {
+      continue;
+    }
+    // Handle $type = 'file' and 'external'.
+    elseif (!cdn_check_file($key)) {
+      $javascript[$key]['preprocess'] = FALSE;
+    }
+  }
+}
+
+/**
  * Implements hook_menu().
  */
 function cdn_menu() {
