Is there a way to disable JS minification for a particular clientlib or JS file?

LinearGradient

15-10-2015

The YUI Compressor cannot compress AngularJS as Angular has some methods such as int(...) that are considered to be reserved words by the YUI Compressor:

15.07.2014 15:32:58.341 *ERROR* [10.66.39.79 [1405402378150] GET /etc/designs/sitesmart/vendor/angular.min.46bb57e637db6fea063f889350401764.js HTTP/1.1] com.day.cq.widget.impl.HtmlLibraryManagerImpl Error during assembly of library. org.mozilla.javascript.EvaluatorException: Compilation produced 52 syntax errors.

You can reproduce the compression issue here: http://refresh-sf.com/yui/ (just upload the angular.js file).

In order to fix this issue, is there a way to skip minification for some specific JS files and/or clientlibs?

Accepted Solutions (1)

Accepted Solutions (1)

Sham_HC

15-10-2015

OOB not possible & you might need to implement own HTMLLibraryManager.  File daycare requesting feature pack.

If you have taken look at [1] you can take advantage of selector and at dispatcher OR linkrewriter remove .min for your request.

[1]  http://aemfaq.blogspot.com/2013/05/whats-new-in-aem-html-library-manager.html

Answers (7)

Answers (7)

mateusp92385321

25-05-2018

Change the minification engine for client libraries in AEM

According to the documentation above, you can change the minification engine for a specific clientlib on AEM version 6.2 and above.

Following up on that, to disable minification, you could add the following property and values to your clientlib .content.xml:

jsProcessor="[default:none, min:none]"

AndreaG-mm

20-07-2020

I just came to a similar problem today got the solution from this page https://helpx.adobe.com/au/experience-manager/kb/how-to-change-the-minification-engine-for-client-li...

 

 

You can add the following property to your client library folder and won't be minified.

jsProcessor: ["default:none", "min:none"]

 

MaxBarrass

27-11-2017

You could always do this, just include a link to your client libs folder directory without using JSTL:

<link rel="stylesheet" href="https://forums.adobe.com/etc/clientlibs/aemdesign/clientlibs-common-head.css" type="text/css">

<script type="text/javascript" src="/etc/clientlibs/aemdesign/clientlibs-common-head.js"></script>

this will add the timstamp but wont minify

LinearGradient

15-10-2015

Bruce Lefebvre wrote...

Hi LinearGradient,

I don't know of a way to exclude specific clientlibs from minification.

That said, I've worked around this bug by simply using the pre-minified version provided by Angular, which YUI has no problem minifying.

 

Unfortunately I don't like this approach. Because double minifying makes it impossible to use Angular's source map file and makes debugging very hard.

Bruce_Lefebvre

Employee

15-10-2015

Hi LinearGradient,

I don't know of a way to exclude specific clientlibs from minification.

That said, I've worked around this bug by simply using the pre-minified version provided by Angular, which YUI has no problem minifying.

LinearGradient

15-10-2015

Hi Alva,

Looks like my question was not clear enough.

I already have minification turned on, but CQ 5's minification library (YUI Compressor) has a known bug that makes it break when it tries to minify the angular.js library: https://github.com/yui/yuicompressor/issues/47

So the question is, is there a way to have minification turned on globally, but skip minification just for a particular clientlib?

Thanks.