Uglify modifies code in minified builds
Justin Obara
obara.justin at gmail.com
Wed Nov 25 17:11:48 UTC 2015
Currently the build process is either minified or source, and it looks like the minified version is the one being used for the build site. It could be an option to change the build process to produce both a minified and source version, and to host both of these on the daily build site.
On November 25, 2015 at 11:33:09 AM, 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idrc.ocad.ca/pipermail/fluid-work/attachments/20151125/a55ac931/attachment.html>
More information about the fluid-work
mailing list