I have some javascript that runs fine after being compiled through Closure with SIMPLE_OPTIMIZATIONS
. But I would like to perform ADVANCED_OPTIMIZATIONS
which performs dead code removal.
After reading some relevant documentation here, I believe my main()
function, which I call through <body onload="main()">
is being eliminated by my compiler. To confirm this, I put a console.log('hello');
line of code in my main()
function. When opening up the results of Closure compilation with simple and advanced optimizations in a text editor, I can find that console.log('hello');
in the simple version, but it is not present in the advanced version.
So my question is, is there an elegant way to tell the compiler that main()
is not unreachable? (Or perhaps am I doing something else wrong..)