function hook_advagg_modify_js_pre_render_alter

nittany7 advagg.api.php hook_advagg_modify_js_pre_render_alter(&$children, &$elements)
cis7 advagg.api.php hook_advagg_modify_js_pre_render_alter(&$children, &$elements)
mooc7 advagg.api.php hook_advagg_modify_js_pre_render_alter(&$children, &$elements)

Allow other modules to modify $children & $elements before they are rendered.

Parameters

$children: An array of children elements.

$elements: A render array containing:

  • #items: The JavaScript items as returned by drupal_add_js() and altered by drupal_get_js().
  • #group_callback: A function to call to group #items. Following this function, #aggregate_callback is called to aggregate items within the same group into a single file.
  • #aggregate_callback: A function to call to aggregate the items within the groups arranged by the #group_callback function.

See also

advagg_modify_js_pre_render()

advagg_js_compress_advagg_modify_js_pre_render_alter()

Related topics

2 functions implement hook_advagg_modify_js_pre_render_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

advagg_js_compress_advagg_modify_js_pre_render_alter in modules/contrib/advagg/advagg_js_compress/advagg_js_compress.module
Implement hook_advagg_modify_js_pre_render_alter().
advagg_mod_advagg_modify_js_pre_render_alter in modules/contrib/advagg/advagg_mod/advagg_mod.module
Implements hook_advagg_modify_js_pre_render_alter().
1 invocation of hook_advagg_modify_js_pre_render_alter()
advagg_modify_js_pre_render in modules/contrib/advagg/advagg.module
#pre_render callback so elements can be modified before they are rendered.

File

modules/contrib/advagg/advagg.api.php, line 489
Hooks provided by the AdvAgg module.

Code

function hook_advagg_modify_js_pre_render_alter(&$children, &$elements) {
  // Get variables.
  $aggregate_settings['variables']['advagg_js_compressor'] = variable_get('advagg_js_inline_compressor', ADVAGG_JS_INLINE_COMPRESSOR);
  $aggregate_settings['variables']['advagg_js_max_compress_ratio'] = variable_get('advagg_js_max_compress_ratio', ADVAGG_JS_MAX_COMPRESS_RATIO);

  // Do nothing if the compressor is disabled.
  if (empty($aggregate_settings['variables']['advagg_js_compressor'])) {
    return;
  }

  // Do nothing if the page is not cacheable and inline compress if not
  // cacheable is not checked.
  if (!variable_get('advagg_js_inline_compress_if_not_cacheable', ADVAGG_JS_INLINE_COMPRESS_IF_NOT_CACHEABLE) && !drupal_page_is_cacheable()) {
    return;
  }

  // Compress any inline JS.
  module_load_include('inc', 'advagg_js_compress', 'advagg_js_compress.advagg');
  foreach ($children as $key => &$values) {
    if (!empty($values['#value'])) {
      $contents = $values['#value'];
      $filename = drupal_hash_base64($contents);
      advagg_js_compress_prep($contents, $filename, $aggregate_settings, FALSE);
      $values['#value'] = $contents;
    }
  }
}