Minification May No Longer Work if JS Code Contains eval() or with() on DXP 7.0

This article serves as a reference concerning an intended change in the minification process which might break some JavaScript code.

After upgrading from Liferay Portal 6.2 to Liferay DXP 7.0, any JavaScript code that uses eval() or with() may no longer work as expected. After the minification process, variable names have been renamed, causing the data variable inside an eval expression to be undefined.

Here is an example from a view.jsp file:

var view = {

"mRender": function ( data, type, full ) {
                return eval("myFunction(data)");

function myFunction(data){

view["mRender"]("Test OK")    ;


Executing this code snippet (which works in Portal 6.2) will then throw the following error in Liferay DXP 7.0:

Uncaught ReferenceError: data is not defined
    at eval (eval at mRender ((index):1), :1:20)
    at Object.mRender ((index):13)
    at (index):13


Workarounds Available

There are two possible workarounds you may execute.

  1. Refactor the JavaScript code to avoid using eval() or with().
  2. Set com.liferay.portal.servlet.filters.strip.StripFilter=false in the file.

Any one of these workarounds should resolve the issue.

Additional Information

See LPS-44366 for more information about switching to Google Closure Compiler to compress JS files in Liferay DXP 7.0 and Google Closure Compiler restrictions about using eval() and with().

Was this article helpful?
1 out of 2 found this helpful