function advagg_js_compress_advagg_modify_js_pre_render_alter in Advanced CSS/JS Aggregation 7.2
Implements hook_advagg_modify_js_pre_render_alter().
Used compress inline js.
Related topics
File
- advagg_js_compress/
advagg_js_compress.module, line 170 - Advanced CSS/JS aggregation js compression module.
Code
function advagg_js_compress_advagg_modify_js_pre_render_alter(&$children, &$elements) {
// Get variables.
$aggregate_settings['variables']['advagg_js_compressor'] = variable_get('advagg_js_compress_inline', ADVAGG_JS_COMPRESS_INLINE);
// 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_compress_inline_if_not_cacheable', ADVAGG_JS_COMPRESS_INLINE_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 &$values) {
// Compress onload.
if (!empty($values['#attributes']['onload'])) {
$contents = $values['#attributes']['onload'];
$filename = drupal_hash_base64($contents);
advagg_js_compress_prep($contents, $filename, $aggregate_settings, FALSE);
$values['#attributes']['onload'] = $contents;
}
// Compress onerror.
if (!empty($values['#attributes']['onerror'])) {
$contents = $values['#attributes']['onerror'];
$filename = drupal_hash_base64($contents);
advagg_js_compress_prep($contents, $filename, $aggregate_settings, FALSE);
$values['#attributes']['onerror'] = $contents;
}
// Compress inline.
if (!empty($values['#value'])) {
$contents = $values['#value'];
$filename = drupal_hash_base64($contents);
advagg_js_compress_prep($contents, $filename, $aggregate_settings, FALSE);
$values['#value'] = $contents;
}
}
unset($values);
}