function advagg_mod_js_alter

cis7 advagg_mod.module advagg_mod_js_alter(&$js)
cle7 advagg_mod.module advagg_mod_js_alter(&$js)
elmsmedia7 advagg_mod.module advagg_mod_js_alter(&$js)
icor7 advagg_mod.module advagg_mod_js_alter(&$js)
meedjum_blog7 advagg_mod.module advagg_mod_js_alter(&$js)
mooc7 advagg_mod.module advagg_mod_js_alter(&$js)

Implements hook_js_alter().

File

sites/all/modules/ulmus/advagg/advagg_mod/advagg_mod.module, line 137
Advanced aggregation modifier module.

Code

function advagg_mod_js_alter(&$js) {
  if (module_exists('advagg') && !advagg_enabled()) {
    return;
  }

  // Only add JS if it's actually needed.
  if (variable_get('advagg_mod_js_remove_unused', ADVAGG_MOD_JS_REMOVE_UNUSED)) {
    advagg_remove_js_if_not_used($js);
  }

  // @ignore sniffer_whitespace_openbracketspacing_openingwhitespace:5
  // Change sort order so aggregates do not get split up.
  if (variable_get('advagg_mod_js_adjust_sort_external', ADVAGG_MOD_JS_ADJUST_SORT_EXTERNAL) || variable_get('advagg_mod_js_adjust_sort_inline', ADVAGG_MOD_JS_ADJUST_SORT_INLINE) || variable_get('advagg_mod_js_adjust_sort_browsers', ADVAGG_MOD_JS_ADJUST_SORT_BROWSERS)) {
    advagg_mod_sort_css_js($js, 'js');
  }

  // Move all JS to the footer.
  $move_js_to_footer = variable_get('advagg_mod_js_footer', ADVAGG_MOD_JS_FOOTER);
  if (!empty($move_js_to_footer)) {
    foreach ($js as $name => &$values) {
      if ($move_js_to_footer == 1 && $values['group'] <= JS_LIBRARY) {
        continue;
      }
      // If JS is not in the header increase group by 10000.
      if ($values['scope'] != 'header') {
        $values['group'] += 10000;
      }
      // If JS is already in the footer increase group by 10000.
      if ($values['scope'] == 'footer') {
        $values['group'] += 10000;
      }
      $values['scope'] = 'footer';
    }
  }

  // Do not use preprocessing if JS is inlined.
  // Do not use defer if JS is inlined.
  if (advagg_mod_inline_page()) {
    advagg_mod_inline_js($js);
    return;
  }

  // Force all JS to be preprocessed.
  if (variable_get('advagg_mod_js_preprocess', ADVAGG_MOD_JS_PREPROCESS)) {
    foreach ($js as $name => &$values) {
      $values['preprocess'] = TRUE;
    }
  }

  // Add the defer tag to all JS.
  if (variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER)) {
    foreach ($js as $name => &$values) {
      // Everything is defer.
      $values['defer'] = TRUE;

      if (strpos($name, 'jquery.js') !== FALSE || strpos($name, 'jquery.min.js') !== FALSE) {
        // Do not defer the loading of jquery.js
        $values['defer'] = FALSE;

        // jquery_update fallback.
        if (module_exists('jquery_update')) {
          $values['onload'] = "if (typeof window.init_drupal_jquery_update_fallback === 'function') {init_drupal_jquery_update_fallback();}";
        }
      }
      if (strpos($name, 'jquery-ui.js') !== FALSE || strpos($name, 'jquery-ui.min.js') !== FALSE) {
        // Do not defer the loading of jquery-ui.js
        $values['defer'] = FALSE;

        // jquery_update fallback.
        if (module_exists('jquery_update')) {
          $values['onload'] = "if (typeof window.init_drupal_jquery_ui_update_fallback === 'function') {init_drupal_jquery_ui_update_fallback();}";
        }
      }

      // Drupal settings.
      if ($name == 'misc/drupal.js') {
        $values['onload'] = "if (typeof window.init_drupal_core_settings === 'function') {init_drupal_core_settings();}";
      }

    }
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.