How do I prevent keyword blocking when using Google Closure Compiler?

I am trying to obfuscate javascript files (about 50) using the Google Closure compiler. all files depend on each other.

In simple mode, it only obfuscates local variables.

In advanced mode, it obfuscates all variables and functions, including certain keywords that I don't want obfuscation (args, readline, atEnd).

How can I confuse some variables, but not others? In particular: I don't want the keywords to be confusing.

+3


source to share


2 answers


There is a fairly significant difference between the ADVANCED

and modes SIMPLE

. Advanced optimizations are only suitable for codebases that are intended to not violate any compiler constraints . Before proceeding, you can read Which compilation level is right for me?

The answers to your question are externs and export:



  • Externs prevent the compiler from renaming symbols in external libraries
  • Export saves symbols in your code for use elsewhere
+1


source


I have no experience with the Google Closure compiler, but I use Jscrambler to obfuscate my projects. This allows them to prevent keyword blocking by using a blacklist they call Rename Exclusion List . I use this function sometimes when I have delicate function names that would otherwise break my code if they were confusing.



+1


source







All Articles