javascript - Closure compiler advanced - 任何性能影响?

标签 javascript performance compression google-closure-compiler

在线闭包编译器很棒:

http://closure-compiler.appspot.com/home

但是,当使用高级选项时,它会完全影响脚本的性能吗? IE,一般来说它会变快还是变慢,还是取决于脚本本身?或者根本没有性能影响?

我问这个是因为我写的一些脚本对性能很关键,我知道这个问题的答案是“试试看”,但我不太擅长运行这类测试,我不知道从哪里开始。

最佳答案

这是来自 Closure Compilier faq 的两点您可能会感兴趣。

Does the compiler make any trade-off between my application's execution speed and download code size?

Yes. Any optimizing compiler makes trade-offs. Some size optimizations do introduce small speed overheads. However, the Closure Compiler's developers have been careful not to introduce significant additional runtime. Some of the compiler's optimizations even decrease runtime (see next question).

Does the compiler optimize for speed?

In most cases smaller code is faster code, since download time is usually the most important speed factor in web applications. Optimizations that reduce redundancies speed up the run time of code as well.

所以这似乎取决于您编写的代码。可能会更快,但也有可能会慢一点。最终,将需要进行测试。

关于javascript - Closure compiler advanced - 任何性能影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5017797/

相关文章:

javascript - Visual Studio 2013 JavaScript/TypeScript 奇怪的缩进行为

javascript - 什么是 ES7 异步函数?

javascript - 设置间隔和清除间隔。出事了

javascript - 如何检查 WKWebView 是否加载了 HTML 字符串

android - 如何在应用程序开发期间测量 Android 上的 FPS

python - 为什么性能会随着数据帧的大小而下降?

c# - 引用平等表现差异? ((object)obj1 == (object)obj2) 与 object.ReferenceEquals( obj1, obj2 )

r - 如何在使用 rredis 从 R 编写的 Redis 中实现数据压缩以减少内存使用?

c# - 使用 GZipStream 压缩空输入导致 C# 中的无效 gz 文件

http - 低流量网站上的 HTTP 压缩(GZip 或 deflate)真的有用吗?