I need to get the JS version of Closure Compiler working in a browser web app. First of all this has been tricky - the documentation appears to only say it's possible, and little else, so I've been more or less reverse engineering my way to something that works in the browser. Some extra documentation on this would be handy.
Anyway I got it working by getting jscomp.js from `npm pack google-closure-compiler-js` which loads and runs in a browser, and jscomp.compile() works if you use the magic option { jsCode: [{ src: "..." }] }.
On a high-end development desktop machine, it takes about a minute to compile testinput.js (an ~800kb script that our web app would process). It's about the same in both Chrome and Firefox. An equivalent `npx google-closure-compiler` command takes 4-5 seconds. This means the browser version is over 10 times slower.
I'm kind of confused about this - isn't npx basically running the same code? Why would the same code be so much slower in the browser? It seems like either something must have gone wrong, or there is obvious low hanging fruit to improve the situation.
To compound the problem it's even slower in a web worker, taking several minutes in Chrome stable - but that seems to be an unrelated issue, it's roughly the same again in Chrome Canary.
Have I done something wrong here? Does anyone have any ideas about how to make Closure Compiler run faster in the browser?
Ashley