YUI Compressor:什么是微优化? [英] YUI Compressor: What are micro optimizations?
本文介绍了YUI Compressor:什么是微优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
YUI Compressor在其(不是很广泛)的文档中将此作为一种选择:
YUI Compressor, in its (not very extensive) documentation states this as an option:
--disable-optimizations
Disable all the built-in micro optimizations.
有人知道这意味着什么吗?
这将打开/关闭什么?
我还没有找到任何相关文档.
Does anyone know what this means?
What will this turn on/off?
I haven't found any documentation about it.
谢谢!
推荐答案
查看JavaScriptCompressor的来源:
Looking at the source of JavaScriptCompressor:
行548 -
if (!disableOptimizations) {
optimizeObjectMemberAccess(this.tokens);
optimizeObjLitMemberDecl(this.tokens);
}
行467 -
/*
* Transforms obj["foo"] into obj.foo whenever possible, saving 3 bytes.
*/
private static void optimizeObjectMemberAccess(ArrayList tokens) {
行497 -
/*
* Transforms 'foo': ... into foo: ... whenever possible, saving 2 bytes.
*/
private static void optimizeObjLitMemberDecl(ArrayList tokens) {
因此,它正在将foo['bar']
中的常量字符串的使用转换为foo.bar
,并将{'bar':x}
中的常量字符串的使用转换为{bar:x}
.
So it's converting use of constant strings in foo['bar']
to foo.bar
and {'bar':x}
to {bar:x}
.
这篇关于YUI Compressor:什么是微优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文