Uglify modifies code in minified builds

Justin Obara obara.justin at gmail.com
Wed Nov 25 16:16:18 UTC 2015



I was code reviewing FLUID-5759 this morning and was looking into the change that was made. I was trying to step through the debugger to compare the change against what had previously been in the codebase. I went to the build site to step through the tests. First off the code for Infusion is all minified; however, Safari does a decent job of separating the code to make it readable. Unfortunately I still could not find the part of the code I was looking for. 

After more digging I found the line I wanted but noticed that the code was actually different. I checked through the repository and confirmed that it was not an issue with the code being out of sync. After running some local builds it seems that the reason is the compression being done by Uglify. It seems that be default most of the compression options are enabled.

Example of the change:

In source:
            if (!fluid.isPrimitive(thisCompositeOptions.panels)) {
                fluid.each(thisCompositeOptions.panels, function (subpanelArray, pref) {
                    subPanelList = subPanelList.concat(subpanelArray);
                    if (pref !== "always") {
                        fluid.each(subpanelArray, function (onePanel) {
                            fluid.set(subPanelRenderOn, onePanel, pref);
                        });
                    }
                });
            } else {
                subPanelList = thisCompositeOptions.panels;
            }

In minified:
fluid.isPrimitive(thisCompositeOptions.panels)?subPanelList=thisCompositeOptions.panels:fluid.each(thisCompositeOptions.panels,function(subpanelArray,pref){subPanelList=subPanelList.concat(subpanelArray),"always"!==pref&&fluid.each(subpanelArray,function(onePanel){fluid.set(subPanelRenderOn,onePanel,pref)})})

So far it doesn’t seem to have caused any issues, and they do disable “unsafe” compression options by default. In theory it should be safe to leave these on. However, it will mean we have a difference in code between the minified and source versions. Which, in the least, will make tracking down code between the two more difficult. 

What are you thoughts, should we keep the full compression or use smaller subset?

infusion-all.js with full default compression options is 831KB

infusion-all.js with the following options disabled, is 844KB

                compress: {
                    sequences: false,
                    dead_code: false,
                    conditionals: false,
                    booleans: false,
                    unused: false,
                    if_return: false,
                    join_vars: false,
                    drop_console: false
                }

Thanks
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idrc.ocad.ca/pipermail/fluid-work/attachments/20151125/2976e5bf/attachment.html>


More information about the fluid-work mailing list