Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closure Compiler: size increases because of many $jscomp statements in output file

Until now, closure compiler (java version) has done a good job of minimising my js files. But recently I've been trying to compile a small service worker js file, and am finding that the size actually increases after compilation.

What I find in the "minimised" code is a lot of statements like:

$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol

I'm just using defaults in the compilation:

$ java -jar compiler.jar service-worker.js > minified.js

Trying this on the code from here (in the section "Service Worker's JavaScript"), the file size goes from 2.6 KB to 7.6 KB!!

But when I run the same code through the online closure compiler app, I get a much smaller file, without all of the above types of statement.

How do I produce the same type of output, without all the bloat, from the local java version of the closure compiler?

like image 990
drmrbrewer Avatar asked Aug 26 '17 10:08

drmrbrewer


1 Answers

The code you are seeing is the ES6 runtime polyfills. If you don't need them, you can disable their injection by setting the --rewrite_polyfills=false flag.

like image 52
Chad Killingsworth Avatar answered Sep 18 '22 20:09

Chad Killingsworth