Minify JS file behaves different than original one

My web-page works with my non-minified JS code. As soon as I minify the code, it doesn't work anymore.

Original code:

$(function(){
  myfunc1();
  $('[a="popover"]').popover();

    // run only on specifc page
    if($("#myobj").val()){...

Is converted to:

$(function(){
if(myfunc1(),$('[a="popover"]').popover(),$("#date-1").val()){
...

which means only if myfunc1() returns true, the other code is executed. Which means, if myfunc1() fails, the code for if($("#myobj")){...} is never executed. This is a pretty different behavior because, in the original code, the code after myfunc1() always gets executed.

Is this a known problem? Or a special feature of minify?

Good question. I haven’t ever gotten the minify feature to actually work correctly since it was added. I’d gladly use it if it worked.

Same for the exporting of only the images used. It doesn’t read anything from JS files or scripts so if you have special scripts using images it ignores them. So that export feature ends up useless to me pretty much 100% of the time.

I’m starting to wonder if the app is just not going to ever be compatible with features that require it to utilize or read JS files/scripts. Seems that most of the export issues are JS issues.

@robert_m_muench

I ran into something similar awhile ago. What I remember is that my javascript was not ECMAScript 5 (ES5) but rather ES2015+ (ES6+).

I believe when you choose to minify, uglify.js is used and it only supports ECMAScript 5 (ES5).

You might try convert the ES6 back to ES5 and then see if it works. Just an idea from something I ran into......

First, good to see I'm not the only one having problems with it.

Then, I don't think it's related to ES5 or ES6, my code is pretty simple and straight forward. The problem you can see within the short code-snippet is, that the minified version changes the code logic. So, I don't get the same behavior as my code, and that's a no go.

So, going to put this feature on the red-list until it's working stable.

Thank you for starting this thread!

Bootstrap Studio used uglify in the past, but as @Twinstream mentioned it doesn't support ES6. This is why we migrated to terser a few months ago. We haven't updated the library since then, and it's possible this minification issue has been fixed. We'll update the library in our next release.