The online closure compiler is amazing:
http://closure-compiler.appspot.com/home
However, when using the advanced option, will it affect performance of the script at all? IE, will it make it faster or slower in general, or does it depend on the script itself? Or i开发者_StackOverflow中文版s there no performance hit at all?
I only ask this as some scripts I write will be performance critical, and I know the answer to this question is "try and see" but I'm not very good at running these sorts of tests, I don't know where to start.
Here are two points from the Closure Compilier faq that may interest you.
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.
So it would seem that it will depend on the code you've written. Could be faster, but there's a chance it could be a little slower. Ultimately, testing will be required.
精彩评论