Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Minification failing for third party JS

Avatar

Level 4

Hi,

We have third party JS files in out project. When we are configuring the Felix console to minify the JS, the minified JS is not getting loaded in the page. Felix uses YUI compressor and when we tested it with online minifier that uses YUI compressor we were able to replicate the error.

However some other minifier e.g. https://javascript-minifier.com/ was able to minify this particular JS without any problem.

What is workaround? Is it possible to configure AEM not to use YUI for minification?

Has anyone faced such issue. Please respond.

AEM version 6.0 SP2.

Regards,

Anil 

1 Accepted Solution

Avatar

Correct answer by
Level 3

We've encountered minification problems as well. We've identified the root cause as being a key in a js object called extends. 

Example of a snippet would be 

var foo ={ extends: 'div' }

Other minification processes wraps the extends with quotes.

var foo ={ "extends": 'div' }

We've used that wrapping as quotes as a workaround in our own code base to allow the minification to work as expected

View solution in original post

6 Replies

Avatar

Employee

Do you see something in the log around this?

Usually there are syntax errors that cause the minification to fail.

Avatar

Level 4

The third party JS seems to be an already minified version. Will check with an unminified version. Does YUI fails when processing a minified version of file.

Avatar

Employee

Please check the error.log file, to check if you see a message around this. Then you know what is causing the minification to fail.

Avatar

Level 1

Hi Feike,

I also meet this problem recently. I can use the Uglify to compress my Js file, it will fails when I try to use YUI compressor.

The file I want to compressed invoke React, And I already use babel to translate it to ES5 synax.

As you know the YUI Compressor is already stopping upgrades long time ago, maybe it not supports the new tech.

Is there any solution I can replace YUI on AEM?

Avatar

Employee

What you can consider too, is to disable minify on publish. And to do this on Apache.

Avatar

Correct answer by
Level 3

We've encountered minification problems as well. We've identified the root cause as being a key in a js object called extends. 

Example of a snippet would be 

var foo ={ extends: 'div' }

Other minification processes wraps the extends with quotes.

var foo ={ "extends": 'div' }

We've used that wrapping as quotes as a workaround in our own code base to allow the minification to work as expected