Legacy Knowledge Base
Published Jul. 2, 2025

JavaScript Minifier does not shorten variable/parameter names

Written By

Jose L. Bango

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

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 to v20180204, 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

 

Did this article resolve your issue ?

Legacy Knowledge Base