You are here

protected function SingleAssetOptimizerBase::isMinified in Advanced CSS/JS Aggregation 8.3

Same name and namespace in other branches
  1. 8.4 src/Asset/SingleAssetOptimizerBase.php \Drupal\advagg\Asset\SingleAssetOptimizerBase::isMinified()

Check if the asset is already minified.

Parameters

string $contents: The asset contents.

Return value

bool TRUE if the asset appears to be already minified.

2 calls to SingleAssetOptimizerBase::isMinified()
CssMinifier::optimize in advagg_css_minify/src/Asset/CssMinifier.php
Optimize the asset's content.
JsMinifier::optimize in advagg_js_minify/src/Asset/JsMinifier.php
Optimize the asset's content.

File

src/Asset/SingleAssetOptimizerBase.php, line 95

Class

SingleAssetOptimizerBase
A base class for optimizing (especially minifying) assets.

Namespace

Drupal\advagg\Asset

Code

protected function isMinified($contents) {

  // If a lot of semicolons probably already minified.
  $semicolon_count = substr_count($contents, ';');
  if ($semicolon_count > 10 && $semicolon_count > substr_count($contents, "\n")) {
    return TRUE;
  }
  return FALSE;
}