You are here

public function MinificationSubscriber::minifyJs in Advanced CSS/JS Aggregation 8.3

Same name and namespace in other branches
  1. 8.4 advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_ext_minify\EventSubscriber\MinificationSubscriber::minifyJs()

Pass the minification over to the minification service.

Parameters

\Drupal\advagg\Asset\AssetOptimizationEvent $asset: The asset optimization event.

File

advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php, line 63

Class

MinificationSubscriber
Subscribe to asset optimization events and minify assets.

Namespace

Drupal\advagg_ext_minify\EventSubscriber

Code

public function minifyJs(AssetOptimizationEvent $asset) {
  if (!$this
    ->isEnabled('js')) {
    return;
  }
  $content = $asset
    ->getContent();
  $content = $this->minifier
    ->js($content, $asset
    ->getAsset(), $asset
    ->getData());
  $asset
    ->setContent($content);
}