You are here

function _prod_check_preprocess_js in Production check & Production monitor 6

Same name and namespace in other branches
  1. 7 prod_check.module \_prod_check_preprocess_js()

File

./prod_check.module, line 1182

Code

function _prod_check_preprocess_js($caller = 'internal') {
  $check = array();
  $state = TRUE;
  $title = 'Optimize JavaScript files';
  $path = 'admin/settings/performance';

  // Check settings.
  if (variable_get('preprocess_js', 0) == 0) {
    $state = FALSE;

    // Check if Advanced CSS/JS Aggregation is being used
    if (module_exists('advagg') && module_exists('advagg_js_compress')) {
      $title = 'Advanced JS Aggregation';
      $path = 'admin/settings/advagg/js-compress';
      if (variable_get('advagg_enabled', TRUE) && variable_get('advagg_js_compress_agg_files', TRUE)) {
        $state = TRUE;
      }
    }
  }
  if ($caller != 'internal') {
    $path = PRODCHECK_BASEURL . $path;
  }
  $check['prod_check_preprocess_js'] = array(
    '#title' => t($title),
    '#state' => $state,
    '#severity' => $caller == 'nagios' ? NAGIOS_STATUS_WARNING : PROD_CHECK_REQUIREMENT_WARNING,
    '#value_ok' => t('Enabled'),
    '#value_nok' => t('Disabled'),
    '#description_ok' => prod_check_ok_title($title, $path),
    '#description_nok' => t('Your !link settings are disabled, ideally they should be enabled on a producion environment but this requires testing first, since it can cause JavaScript errors in certain cases.', prod_check_link_array($title, $path)),
    '#nagios_key' => 'JCOMP',
    '#nagios_type' => 'state',
  );
  return prod_check_execute_check($check, $caller);
}