CRM_Utils_JS
class CRM_Utils_JS
Parse Javascript content and extract translatable strings.
Methods
Parse a javascript file for translatable strings.
Identify duplicate, adjacent, identical closures and consolidate them.
This is a primitive comment stripper. It doesn't catch all comments and falls short of minification, but it doesn't munge Angular injections and is fast enough to run synchronously (without caching).
Details
at line 43
static array
parseStrings(string $jsCode)
Parse a javascript file for translatable strings.
at line 81
static string
dedupeClosures(array $scripts, array $localVars, array $inputVals)
Identify duplicate, adjacent, identical closures and consolidate them.
Note that you can only dedupe closures if they are directly adjacent and have exactly the same parameters.
at line 124
static string
stripComments(string $script)
This is a primitive comment stripper. It doesn't catch all comments and falls short of minification, but it doesn't munge Angular injections and is fast enough to run synchronously (without caching).
At time of writing, running this against the Angular modules, this impl of stripComments currently adds 10-20ms and cuts ~7%.
Please be extremely cautious about extending this. If you want better minification, you should probably remove this implementation, import a proper JSMin implementation, and cache its output.