Uglify modifies code in minified builds
Steve Lee
steve at opendirective.com
Wed Nov 25 17:20:35 UTC 2015
Interesting thread. I've not used uglify but assumed from the name
that it's purpose was to mangle code - but I see that is just one
option.
I'm probably teaching granny to suck eggs but in compiled source
development like C you almost always have 2 separate builds.
* debug: not code mangling optimisations so can easily debug, plus
create debug symbols
* release (deploy) - high optimisation which changes the code and so
hard to debug.
Release builds are hard to debug but core and JIT crash debuggers do
exist that attempt to unwind the optimisations.
So I find it interesting in your discussion. I guess as an open source
project there is no need to mangle, but optimisation is important (at
least till HTTP/2 is used everywhere).
It does seem that most web optimisations are non mangling compression
and the JIT javascript is left to figure it out.
At least if you transpile (eg ES6 to ES5) you get source maps which help debug.
Anyway sorry I have little to add other than these are really new
issues, just a different spin. There must be good answers.
Steve Lee
OpenDirective http://opendirective.com
On 25 November 2015 at 16:33, Tirloni, Giovanni <gtirloni at ocadu.ca> wrote:
> 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
> _______________________________________________________
> fluid-work mailing list - fluid-work at lists.idrc.ocad.ca
> To unsubscribe, change settings or access archives,
> see http://lists.idrc.ocad.ca/mailman/listinfo/fluid-work
More information about the fluid-work
mailing list