-
Notifications
You must be signed in to change notification settings - Fork 570
What about tree shaking like in Dart to make compiled files smaller? #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is "tree shaking" the same thing as "dead code elimination"? If so, GopherJS already does that, but it can't do it as thoroughly as one might hope due to reflection - it's hard to know in advance what may or may not be used via reflection (see related issue #136). There's an issue to perform more aggressive DCE, see #186, which seems like the best hope at helping with file sizes (with some tradeoffs). |
I think yes. I very hope the author implement it very soon and results will satisfactory. Also I'm a little bit confused why the |
Me too. If I'm not mistaken, aggressive DCE (#186) is @neelance's current highest priority goal for GopherJS.
@dominikh can comment on that. But it's considered the canonical DOM package for GopherJS, as can be seen here. |
Regarding "tree shaking"/dead code elimination: Like @shurcooL said, GopherJS does have DCE, but due to the way Go's reflection works, it's quite limited. Reflection allows access to all exported methods of a type, so all types used in those methods in turn cannot be eliminated. Although #186 could address that. However, that still wouldn't help with e.g. my
It's not part of the |
All said above is correct. GopherJS already features dead code elimination and there will be a more aggressive version in the future (#186). @kalopsia You are mentioning slower mobile phones. Do you have some concrete numbers? I think even a 600MHz processor should be able to decompress 1MB in just a few milliseconds. |
Thanks for reply! I got it. Now I can close the issue.
Nope, don't worry, it's purely my assumption) |
Hello, today I've tried your package and it is incredible! Really good job!) Included
gopherjs build ... -w
works very-very good! However, the problem is the compiled file size. It's too big (consider mobile phones with 600Mhz processors that will hardly parse 300kb of gzipped archive into > 1mb files). I know that there is no way without constant overhead to ensure compliance with the Go specification. However look at Dartlang.$ dart2js main.dart
The result:
out.js
takes 0.069 MB without gzip and minifying.Now the same version with Gopherjs and
dom
package:$ gopherjs build main.go
The result:
main.js
takes 1.1 MB without gzip and minifying.As far as I understand this good result is possible due to tree shaking.
If the Dart team have done it, you can do as well..I think. What about including in the build only what is actually used in the source code?
The text was updated successfully, but these errors were encountered: