AEM Clientlib Minification issue and how to debug-

Debal Das
3 min readJun 26, 2022

--

We all know that minification allows us to reduce the size of the files being requested.

We also know that AEM provides an OOTB OSGi configuration to enable minification on the instances which in time will reduce the size of the Javascript (JS)/CSS files being requested, improving the loading time of the pages.

But many times minification didn’t work despite being this AEM OOTB OSGi configuration enabled on AEM clientlibs.

Personally I had encountered this issue and even I have seen several posts specially with ECMASCRIPT6 minification isn’t working or clientlib isn’t getting minified.

Now I will talk about how can we debug this issue here.

Approach:1

Like any other issue we always start the debug with log file so, no exception in this case also.

We need to check error.log file of the relevant AEM instance and then search with the file name like clientlib.min.js or clientlib.js

Please don’t get confused with .min. in that file name. I know it looks like file gets minified but it actually don’t.

Here definitely you will be seeing some error associated with that clientlib like the below one -

ERROR* [0:0:0:0:0:0:0:1 [1652861958525] GET ……

ECMASCRIPT6 mode or better: block-scoped function declaration.

When I had this minification issue, immediately I shared the error message with Front End team and then they took necessary steps to fix this issue.

We can go one step further and follow below approach also -

Approach:2

To troubleshoot the issue we need to follow the below steps -

a. AEM 6.5 uses following closure-compiler-v20190121.jar for Javascript minification, also highlighted in below screenshot -

b. If we take a closure look , we could see com.google.javascript is part of this closure compiler bundle.

c. Next we need to download the bundle:closure-compiler-v20190121.jar from aeminstance\crx-quickstart\launchpad\felix\bundle290\version0.0\bundle.jar-embedded. Bundle ID may vary in your case-

d. To understand the minification issue , we need to execute below command to compile the Javascript file -

java -jar compiler.jar — js hello.js — js_output_file hello-compiled.js

Here , compiler.jar is nothing but closure-compiler-v20190121.jar

It may throw error during compilation and this error message will help us to understand why minification isn’t working.

Personally I have seen in my project Front End developers do the minification outside as part of the Frontend build process, Front End developers would not rely on the AEM features, because there are better ways and tools to do so.

Please refer the following link : Getting Started with the Closure Compiler Application | Google Developers to know Closure Compiler.

Hope you will enjoy it …

--

--