Languages
[Edit]
EN

JavaScript - minify js files with google-closure-compiler under npm on Windows

9 points
Created by:
Marcin
19550

In this short article, we would like to show how to useĀ google-closure-compiler to compile js files to minified versions (*.min.js) on Windows.

The article contains two parts:

  1. usage npm / npx,
  2. installation with npm.

Simple usage:

npx google-closure-compiler --js=input.js --js_output_file=output.min.js

Ā 

Note:Ā online version is availableĀ here.

Check out this article -Ā JavaScript - minify js files with Google Closure Compiler Service (online)

Compression result:

js file compressed with google-closure-compiler
js file compressed with google-closure-compiler

Note: go to instalation section if you are using compiler first time.

Ā 

Installation example

In this section, we can see how to installĀ google-closure-compilerĀ using npm. It can take few seconds so be patient until installation will succeed.

Run the following command:

npm install -g google-closure-compiler

Where -g means global installation.

Example output:

C:\Users\john\AppData\Roaming\npm\google-closure-compiler -> C:\Users\john\AppData\Roaming\npm\node_modules\google-closure-compiler\cli.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: google-closure-compiler-osx@^20200920.0.0 (node_modules\google-closure-compiler\node_modules\google-closure-compiler-osx):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for google-closure-compiler-osx@20200920.0.0: wanted {"os":"darwin","arch":"x64,x86"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: google-closure-compiler-linux@^20200920.0.0 (node_modules\google-closure-compiler\node_modules\google-closure-compiler-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for google-closure-compiler-linux@20200920.0.0: wanted {"os":"linux","arch":"x64,x86"} (current: {"os":"win32","arch":"x64"})

+ google-closure-compiler@20200920.0.0
added 28 packages from 73 contributors in 271.338s

Ā 

See also

  1. JavaScript - compress js files with terser

References

  1. google-closure-compiler online version

Web resources compression / minify (JS, CSS)

Native Advertising
šŸš€
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ā¤ļøšŸ’» šŸ™‚

Join