简体   繁体   English

如何在简单模式下告诉Google Closure Compiler可以压缩特定的函数名称?

[英]How to tell Google Closure Compiler in simple mode that particular function name could be compressed?

Google Closure Compiler does it with ADVANCED_OPTIMIZATIONS option, but I can not use it, since I use jQuery. Google Closure Compiler使用ADVANCED_OPTIMIZATIONS选项实现了此功能,但由于使用jQuery,因此无法使用。 So, I have to use SIMPLE_OPTIMIZATIONS, but I would like to compress names of some functions. 因此,我必须使用SIMPLE_OPTIMIZATIONS,但是我想压缩某些函数的名称。

function myLongFunctionName(response) {
 // do something here
}

myLongFunctionName(text);

I am OK to have myLongFunctionName changed to a (or whatever Closure Compiler chooses). 我行有myLongFunctionName变为a (或任何使用Closure Compiler选择)。 But I don't see any annotation , which could help me. 但是我没有看到任何注释 ,它可以帮助我。 How could I do it? 我该怎么办?

If function is local, then Google Closure Compiler renames it. 如果函数是本地函数,则Google Closure Compiler重命名它。 I've moved my code into 我已将代码移入

(function(){

  function myLongFunctionName(response) {
   // do something here
  }

  myLongFunctionName(text);

})()

In result, it is compressed also. 结果,它也被压缩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM