Closure Compiler: a tool for making JavaScript download and run faster
21–30 of 77 posts
Re: Closure Compiler: a tool for making JavaScript download and run faster
#22Earlier quoted context omitted.
Have a look at the advanced compilation option: https://developers.google.com/closure/compiler/docs/api-tuto... Basically when enabled it will rewrite normal property access, e.g: `myObj.foo` to something like `a.b` but wont shorten string literal access, e.g `myObj['foo']` just becomes `a.foo` which you would use for any API's you want to export. For a real-world example I use string literals for declaring jquip's p…
May i ask why you are using this notation? I honestly can't think of any benefits. Isn't it more convenient and readable to use `p.removeAttr`?
Re: Closure Compiler: a tool for making JavaScript download and run faster
#23Earlier quoted context omitted.
May i ask why you are using this notation? I honestly can't think of any benefits. Isn't it more convenient and readable to use `p.removeAttr`?
My comment explains the entire purpose for using it - if I didn't, it would've got rewritten into `a.b` and none of the public API's would work!
Re: Closure Compiler: a tool for making JavaScript download and run faster
#24Re: Closure Compiler: a tool for making JavaScript download and run faster
#25How can it determine dead code for such a dynamic language like JavaScript? Is it limited to obvious stuff like things after a "return;" statement that cannot run? Because I don't see how it could remove unused functions when you can invoke them in such indirect ways: myobj['f'+'oo']();
Have a look at the advanced compilation option: https://developers.google.com/closure/compiler/docs/api-tuto... Basically when enabled it will rewrite normal property access, e.g: `myObj.foo` to something like `a.b` but wont shorten string literal access, e.g `myObj['foo']` just becomes `a.foo` which you would use for any API's you want to export. For a real-world example I use string literals for declaring jquip's p…
Re: Closure Compiler: a tool for making JavaScript download and run faster
#26Re: Closure Compiler: a tool for making JavaScript download and run faster
#27Earlier quoted context omitted.
My comment explains the entire purpose for using it - if I didn't, it would've got rewritten into `a.b` and none of the public API's would work!
I wish there were a better way to indicate which properties were renameable, because I need this too and I'm not willing to go as far as you did.
https://developers.google.com/closure/compiler/docs/api-tuto...
Re: Closure Compiler: a tool for making JavaScript download and run faster
#28Why is the closure library not as popular as other alternatives (ex: jquery)? It looks like a solid library, used by gmail, google docs and other google apps, I'm guessing is the java requirement for the compiler.
Re: Closure Compiler: a tool for making JavaScript download and run faster
#29Earlier quoted context omitted.
My comment explains the entire purpose for using it - if I didn't, it would've got rewritten into `a.b` and none of the public API's would work!
I wish there were a better way to indicate which properties were renameable, because I need this too and I'm not willing to go as far as you did.
Re: Closure Compiler: a tool for making JavaScript download and run faster
#30Earlier quoted context omitted.
I think it's likely that long-term, the approach FB took with Flow (or more general Abstract Interpretation methods) should be able to handle more cases with less effort on the developer's side (albeit with increased computational costs). The modules/"code motion" is a bit strange at first glance, but definitely a huge boon for building debuggers/admin interfaces/etc. that you don't want included in your main applica…
It's not clear what you're referring to wrt. "the approach FB took with Flow" and Abstract Interpretation. Type checking? Dead code elimination? In anycase, Google Closure Compiler also leverages Abstract Interpretation.
Closure would probably be the most interesting (or close to the most interesting) project to work on inside of Google-proper, for me personally. That said, Google's approach is very much on the opposite side of FB's, in that Google expects the vast majority of code to be written for it. FB is dealing with a legacy codebase and has fewer engineers, so has to strike a different set of tradeoffs - less up-front work to integrate their tooling for potentially less benefit than something like Closure can deliver. It's interesting to see the two different approaches.
Anyway, this thread is about Closure, which enables ClojureScript, which is my go to language these days. The developers working on the compiler and the stdlib (which is amazing) should feel proud about all the people they've enabled.