diff --git a/CRM/Utils/JS.php b/CRM/Utils/JS.php index 0b4673771416..27e52d0d1ffb 100644 --- a/CRM/Utils/JS.php +++ b/CRM/Utils/JS.php @@ -109,7 +109,7 @@ public static function dedupeClosures($scripts, $localVars, $inputVals) { * @return string */ public static function stripComments($script) { - return preg_replace(":^\\s*//[^\n]+$:m", "", $script); + return preg_replace("#^\\s*//[^\n]*$(?:\r\n|\n)?#m", "", $script); } /** diff --git a/Civi/Angular/Page/Modules.php b/Civi/Angular/Page/Modules.php index 96d78867c44d..d7957629ab9b 100644 --- a/Civi/Angular/Page/Modules.php +++ b/Civi/Angular/Page/Modules.php @@ -106,15 +106,14 @@ public static function buildAngularModules($event) { public function digestJs($files) { $scripts = []; foreach ($files as $file) { - $scripts[] = file_get_contents($file); + $scripts[] = \CRM_Utils_JS::stripComments(file_get_contents($file)); } $scripts = \CRM_Utils_JS::dedupeClosures( $scripts, ['angular', '$', '_'], ['angular', 'CRM.$', 'CRM._'] ); - // This impl of stripComments currently adds 10-20ms and cuts ~7% - return \CRM_Utils_JS::stripComments(implode("\n", $scripts)); + return implode("\n", $scripts); } /** diff --git a/ang/crmUi.js b/ang/crmUi.js index 7482999091b9..c6ba58b1464e 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -484,7 +484,6 @@ // $scope.myOrder.setDir('field2', ''); // HTML: