5 ms·
UglifyJS takes about 5 minutes to setup, and it works. It's impossible to reliably set up Closure compiler if you are outside of Google's infrastructure and/or
by dmitriid 10y ago
UglifyJS takes about 5 minutes to setup, and it works.
It's impossible to reliably set up Closure compiler if you are outside of Google's infrastructure and/or outside of Google's Closure Library.
End of comparison.
- thelgevold 10y agoClosure definitely has a steeper learning curve. I also agree that it's not always realistic to use it.
- dmitriid 10y agoI'd say the learning curve is insurmountable. - The official docs are basically non-existent. - If you're lucky enough to realize that GitHub wiki has better docs, good luck figuring them out. - Even though the support for node_modules is kinda finally there, it's still impossible to figure out how to reliably set the compiler in a way that recognizes them. My old-ish rant about this: https://gist.github.com/dmitriid/7bd6f2c10d263bae40e0addc7edd5281 https://gist.github.com/dmitriid/7bd6f2c10d263bae40e0addc7ed...
- krat0sprakhar 10y agoWhile still in experimental stage, I'm hoping the pure JS version of Closure compiler will solve the problem to a large extent. https://github.com/google/closure-compiler-js https://github.com/google/closure-compiler-js
- dmitriid 10y agoAs it's a port of the Java version with the same capabilities, it'll probably have the same problems still. In my personal experience I couldn't get the compiler (none of the versions) work with a simple-enough project and node_modules in all the correct places. UglifyJS just works.
- lobster_johnson 10y agoLuckily, that's not correct. Just pipe your JavaScript into Closure and it will minify it as easily as Uglify. We're migrating to Webpack, but we've been using this for about 4 years: node_modules/.bin/browserify index.js | closure-compiler \ --warning_level quiet \ --third_party \ --jscomp_off es3 \ --compilation_level SIMPLE_OPTIMIZATIONS \ --language_in ECMASCRIPT5 \ --create_source_map "index.min.js.map" \ --output_wrapper "%output%//# sourceMappingURL=/index.min.js.map" \ > index.min.js This generates a minified file plus a source map. Part of the magic happens in Browserify [1], which generates a single file from all your inputs, taking care to follow the import chains in the correct order. If you have ES6 code, you'll just install Babel and add "-r babel-register" to the Browserify command line. I read the rant in your other comment, and I don't understand what it was that you struggled with. You certainly don't need to follow Google's Closure conventions in order for it to optimize and minify your code effectively. We don't; we use React and Babel with all the ES6 bells and whistles, but none of the Google conventions. [1] http://browserify.org http://browserify.org
- dmitriid 10y agoWe moved away from browserify and the need to concatenate everything about two years ago, and we're definitely never going back :) So maybe concatenating everything works with Closure Compiler. I don't know. We couldn't make it work with their advertised support for node_modules.
- lobster_johnson 10y agoWhy do you need to minify if you're not bundling?
- dmitriid 10y agoWe are bundling. That's the last step after all the code has bin babelified etc. So Closure compiler will do nothing, really. And it fails spectacularly on webpack's helper functions that are bundled in (especially if the functions are exctracted to the HTML file)