public function 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Asset!JsOptimizer.php/function/JsOptimizer::clean/8.1.x