NOTE: This article is an INTERNAL article and is not visible to customers, currently. Please only link this article in internal comments, but not public comments.
Issue
- If you configure your Liferay instance like this:
minifier.enabled=true javascript.fast.load=true theme.images.fast.load=true layout.template.cache.enabled=true
JavaScript Minifier removes blanks, line breaks, comments, etc. successfully, but it does not shorten variables or function parameter names. - For instance, if you have:
function foo(bar){ alert(bar); }
you get this output:function foo(bar){alert(bar);}
instead of something like:function foo(a){alert(a);}
- It happens to both Liferay and custom development files.
Environment
- DXP 7.1 or higher
Resolution
- The minification is done by closure-compiler library at runtime.
- Since the upgrade from version
v20131014
tov20180204
, the minifier has not worked as expected: it does not shorten variable/parameter names as described before.- This has not been backported to 7.0.x yet, that's why DXP 7.0 is not affected.
- It is a known bug in closure-compiler library.
- Note that you may find fully minified files (usually YUI files) if they are served this way.
-
Solving the issue means performing a more aggressive minification. Trying to solve it now, after several years, has shown that unexpected errors appear at runtime.
- Note that the fast-load of the resources (serving multiple files in one resource) makes the platform more prone to these errors.
- Furthermore, the presence of custom developed code could raise new errors there when trying more aggressive minification.
- In Liferay DXP 7.4, this minification method (at runtime) has been deprecated in favor of a build-time minification (see LPS-122883).
- Therefore, having all of the above into account, it has been decided that this issue will not be fixed.
Additional Information
- See PTR-2671: closure-compiler library not minifying as expected for further details.