function advagg_js_compress_jspacker in Advanced CSS/JS Aggregation 7
Same name and namespace in other branches
- 6 advagg_js_compress/advagg_js_compress.module \advagg_js_compress_jspacker()
- 7.2 advagg_js_compress/advagg_js_compress.advagg.inc \advagg_js_compress_jspacker()
Compress a JS string using packer.
Parameters
$contents: Javascript string.
1 call to advagg_js_compress_jspacker()
- advagg_js_compress_file_saver in advagg_js_compress/
advagg_js_compress.module - Save a string to the specified destination. Verify that file size is not zero.
File
- advagg_js_compress/
advagg_js_compress.module, line 552 - Advanced CSS/JS aggregation js compression module.
Code
function advagg_js_compress_jspacker(&$contents) {
// Use Packer on the contents of the aggregated file.
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'advagg_js_compress') . '/jspacker.inc';
// Add semicolons to the end of lines if missing.
$contents = str_replace("}\n", "};\n", $contents);
$contents = str_replace("\nfunction", ";\nfunction", $contents);
// Remove char returns, looking at you lightbox2.
$contents = str_replace("\n\r", "", $contents);
$contents = str_replace("\r", "", $contents);
$contents = str_replace("\n", "", $contents);
$packer = new JavaScriptPacker($contents, 62, TRUE, FALSE);
$contents = $packer
->pack();
}