JsOptimizer::clean

public JsOptimizer::clean($contents)

Processes the contents of a javascript asset for cleanup.

Parameters

string $contents: The contents of the javascript asset.

Return value

string Contents of the javascript asset.

Overrides AssetOptimizerInterface::clean

File

core/lib/Drupal/Core/Asset/JsOptimizer.php, line 47

Class

JsOptimizer
Optimizes a JavaScript asset.

Namespace

Drupal\Core\Asset

Code

public function clean($contents) {
  // 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;
}
doc_Drupal
2016-10-29 09:21:37
Comments
Leave a Comment

Please login to continue.