function advagg_mod_advagg_modify_js_pre_render_alter

cis7 advagg_mod.module advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements)
cle7 advagg_mod.module advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements)
elmsmedia7 advagg_mod.module advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements)
icor7 advagg_mod.module advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements)
meedjum_blog7 advagg_mod.module advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements)
mooc7 advagg_mod.module advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements)

Implements hook_advagg_modify_js_pre_render_alter().

File

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

Code

function advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements) {
  if (module_exists('advagg') && !advagg_enabled()) {
    return;
  }

  // Do not use defer/async shim if JS is inlined.
  if (advagg_mod_inline_page()) {
    return;
  }

  if (variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER)) {
    foreach ($children as &$values) {
      $values['#attributes']['defer'] = TRUE;
      if (empty($values['#value'])) {
        continue;
      }

      // Workaround bug with onload and jquery update.
      if (!empty($values['#attributes']['onload'])) {
        unset($values['#attributes']['onload']);
      }

      // Core.
      if (strpos($values['#value'], 'jQuery.extend(Drupal.settings') !== FALSE) {
        $values['#value'] = 'function init_drupal_core_settings() {' . $values['#value'] . '}';
      }

      // JQuery Update.
      if (strpos($values['#value'], 'window.jQuery') !== FALSE) {
        $values['#value'] = 'function init_drupal_jquery_update_fallback() {' . $values['#value'] . '}';
      }
      if (strpos($values['#value'], 'window.jQuery.ui') !== FALSE) {
        $values['#value'] = 'function init_drupal_jquery_ui_update_fallback() {' . $values['#value'] . '}';
      }
    }
  }

  if (variable_get('advagg_mod_js_async_shim', ADVAGG_MOD_JS_ASYNC_SHIM)) {
    foreach ($children as &$values) {
      if (isset($values['#attributes']) && isset($values['#attributes']['async']) && $values['#attributes']['async'] == 'async') {
        $source = url($values['#attributes']['src']);
        $values['#value'] = "(function() {
  var s = document.createElement('script');
  s.type = 'text/javascript';
  s.async = true;
  s.src = '$source';
  var d = document.getElementsByTagName('script')[0];
  d.parentNode.insertBefore(s, d);
})();";
        unset($values['#attributes']['async']);
        unset($values['#attributes']['src']);
      }
    }
  }

}
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.