Uglify modifies code in minified builds
Tirloni, Giovanni
gtirloni at ocadu.ca
Wed Nov 25 16:33:00 UTC 2015
Changing those options seem to be trying to make the uglified code
closer to the original version for understandability purposes.
I wonder if it's not better to always use the non-uglified code when
debugging and only switch focus to the uglified version if the issue
can't be reproduced with the original code (which would point to a issue
with the uglifier). Are we producing non-uglified code during the build
process?
Regarding file size, the difference is so small I'm sure it'll be made
irrelevant by server-side compression before it arrives at the client. A
worse problem is websites that load Infusion multiple times, but I guess
that is not in scope here.
On 11/25/2015 02:16 PM, Justin Obara wrote:
>
>
> I was code reviewing FLUID-5759
> <https://github.com/fluid-project/infusion/pull/655> 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
> <http://build.fluidproject.org> 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 <https://github.com/gruntjs/grunt-contrib-uglify>. It seems
> that be default most of the compression options
> <https://github.com/mishoo/UglifyJS2#compressor-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
More information about the fluid-work
mailing list