Same name in other branches
- 5.0.x advagg_js_minify/src/Asset/JsMinifier.php \Drupal\advagg_js_minify\Asset\JsMinifier::clean()
- 6.0.x advagg_js_minify/src/Asset/JsMinifier.php \Drupal\advagg_js_minify\Asset\JsMinifier::clean()
- 8.x-4.x advagg_js_minify/src/Asset/JsMinifier.php \Drupal\advagg_js_minify\Asset\JsMinifier::clean()
Processes the contents of a javascript asset for cleanup.
Paramètres
string $contents: The contents of the javascript asset.
array $asset: The core asset definition array.
Return value
string Contents of the javascript asset.
1 call to JsMinifier::clean()
- JsMinifier::optimize dans advagg_js_minify/
src/ Asset/ JsMinifier.php - Optimize the asset's content.
Fichier
-
advagg_js_minify/
src/ Asset/ JsMinifier.php, line 101
Classe
- JsMinifier
- Optimizes a JavaScript asset.
Namespace
Drupal\advagg_js_minify\AssetCode
public function clean($contents, array $asset) {
if ($encoding = Unicode::encodingFromBOM($contents)) {
$contents = mb_substr(Unicode::convertToUtf8($contents, $encoding), 1);
}
elseif (isset($asset['attributes']['charset'])) {
$contents = Unicode::convertToUtf8($contents, $asset['attributes']['charset']);
}
// Remove JS source and source mapping urls or these may cause 404 errors.
$contents = preg_replace('/\\/\\/(#|@)\\s(sourceURL|sourceMappingURL)=\\s*(\\S*?)\\s*$/m', '', $contents);
return $contents;
}