You are here

function advagg_js_compress_jsmin in Advanced CSS/JS Aggregation 7.2

Compress a JS string using jsmin.

Parameters

string $contents: Javascript string.

bool $log_errors: FALSE to disable logging to watchdog on failure.

1 string reference to 'advagg_js_compress_jsmin'
advagg_js_compress_configuration in advagg_js_compress/advagg_js_compress.module
Generate the js compress configuration.

File

advagg_js_compress/advagg_js_compress.advagg.inc, line 654

Code

function advagg_js_compress_jsmin(&$contents, $log_errors = TRUE) {
  $no_errors = TRUE;
  $contents_before = $contents;
  try {
    $contents = jsmin($contents);
  } catch (Exception $e) {
    $no_errors = FALSE;

    // Log the exception thrown by JSMin+ and roll back to uncompressed content.
    if ($log_errors) {
      watchdog('advagg_js_compress', '@message <pre> @contents </pre>', array(
        '@message' => $e
          ->getMessage(),
        '@contents' => $contents_before,
      ), WATCHDOG_WARNING);
    }
    $contents = $contents_before;
  }
  return $no_errors;
}