使用 Google 的闭包编译器缩小字符串的正确方法是什么?
我正在编写 jQuery 插件,我想通过用枚举替换常用的 CSS 属性字符串来缩小脚本的大小。然而,Google 的闭包编译器将所有字符串变量替换为字符串文字。例如,选择高级优化:
这
var x = "hey bob how are you doing";
alert(x);
alert(x);
alert(x);
alert(x);
将返回
alert("hey bob how are you doing");alert("hey bob how are you doing");alert("hey bob how are you doing");alert("hey bob how are you doing");
What is the right way to do that I'm try to do without getting my code through a stringcompressor like JScrambler?
提前致谢。
I'm in the middle of writing a jQuery plugin, and I'd like to shrink the size of my script by replacing commonly used CSS property strings with enums. However, Google's Closure Compiler replaces all string variables with string literals. For example, with advanced optimization selected:
this
var x = "hey bob how are you doing";
alert(x);
alert(x);
alert(x);
alert(x);
returns
alert("hey bob how are you doing");alert("hey bob how are you doing");alert("hey bob how are you doing");alert("hey bob how are you doing");
What is the right way to do what I'm trying to do without sending my code through a string compressor like JScrambler?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Stephen Chung的回答(所以这个问题可以显示为已回答):
Stephen Chung's answer ( so this question can show as answered ):