Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. JsOptimizer.php

function JsOptimizer::clean

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 80

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal