You are here

function cdn_js_alter in CDN 7.2

Implements hook_js_alter().

Ensure that CDN-blacklisted JS files are not aggregated, so that the JS aggregates can still be served from the CDN.

File

./cdn.module, line 285

Code

function cdn_js_alter(&$javascript) {
  if (!cdn_status_is_enabled()) {
    return;
  }

  // If all JS files are blacklisted, return early, otherwise we'd end up
  // disabling preprocessing (aggregation) for every JS file, hence disabling
  // aggregation altogether.
  if (!cdn_check_file('*.js')) {
    return;
  }
  foreach (array_keys($javascript) as $key) {

    // Skip $type = 'inline'.
    if (is_numeric($key)) {
      continue;
    }
    elseif ($key === 'settings') {
      continue;
    }
    elseif (!cdn_check_file($key)) {
      $javascript[$key]['preprocess'] = FALSE;
    }
  }
}