You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closure keeps IIFEs as-is. Most of the code I compress is not mine, & there either no tests or I don't have time to install & run them. I think many others are in the same situation.
My use case is compressing files before I host them on jsDelivr free CDN. So I prefer to keep code close as authors published it, just smaller.
Program completion value is almost never used.
That may be true. So @michaelficarra if you'd like to make & test a PR everytime I find a program completion in the wild, I can ping you! But I suspect you are good at keeping yourself busy also ;)
@mishoo I don't use build scripts for alot of my compression. I often use online UglifyJS before uploading to the CDN for those rare projects that don't provide minified version. Perhaps I could just fork it & hardcode the flag myself, but I see others don't like that surprise either.
Not every program is wrapped in an IIFE.
Very true! I think I have to deal with more IIFE usage than you. Since jsDelivr only hosts front-end code (1/3 are of the ~1200 projects we host are jQuery plugins), I'll see alot more IIFEs than a CoffeeScript guru like you! 😀
A few even lead with a ; & their concern is well-founded since we do sever-side concocting.
@michaelficarra Indeed. Then nope, we don't have an option for it. Other than negating IIFE-s, the one thing that could affect final value is discarding constant side-effect-free ExpressionStatement-s. I could add an option for it if there's sufficient interest (I personally don't see the point though).
Activity
michaelficarra commentedon Sep 11, 2014
Program completion value is almost never used. esmangle also defaults to not preserving program completion value. 👎.
aside: Is there an option to preserve program completion value in uglifyjs?
tomByrer commentedon Sep 12, 2014
Closure keeps IIFEs as-is. Most of the code I compress is not mine, & there either no tests or I don't have time to install & run them. I think many others are in the same situation.
My use case is compressing files before I host them on jsDelivr free CDN. So I prefer to keep code close as authors published it, just smaller.
That may be true. So @michaelficarra if you'd like to make & test a PR everytime I find a program completion in the wild, I can ping you! But I suspect you are good at keeping yourself busy also ;)
mishoo commentedon Sep 12, 2014
@michaelficarra there is,
-c negate_iife=false.To be honest, this transformation doesn't bring much to the table. The size savings are probably negligible, we could make it off by default.
However, @tomByrer — why don't you simply pass
negate_iife=falsein your build scripts?michaelficarra commentedon Sep 12, 2014
@mishoo that's nowhere near sufficient for completion value preservation. Not every program is wrapped in an IIFE.
tomByrer commentedon Sep 12, 2014
@mishoo I don't use build scripts for alot of my compression. I often use online UglifyJS before uploading to the CDN for those rare projects that don't provide minified version. Perhaps I could just fork it & hardcode the flag myself, but I see others don't like that surprise either.
Very true! I think I have to deal with more IIFE usage than you. Since jsDelivr only hosts front-end code (1/3 are of the ~1200 projects we host are jQuery plugins), I'll see alot more IIFEs than a CoffeeScript guru like you! 😀
A few even lead with a
;& their concern is well-founded since we do sever-side concocting.michaelficarra commentedon Sep 15, 2014
But preserving completion value is not just about IIFEs. It's about not changing the completion value of the final statement in the program.
mishoo commentedon Sep 15, 2014
@michaelficarra Indeed. Then nope, we don't have an option for it. Other than negating IIFE-s, the one thing that could affect final value is discarding
constantside-effect-free ExpressionStatement-s. I could add an option for it if there's sufficient interest (I personally don't see the point though).Edit: s/constant/side-effect-free/
fix negate_iife : false
rvanvelzen commentedon Feb 11, 2015
Closing in favor of #640.
process code with implicit return statement
process code with implicit return statement
process code with implicit return statement
process code with implicit return statement (#1522)