With bigger quantities of script being used in the page, the size of the script itself can become an issue. IIS supports compressing responses, but it is not turned on by default. Text compresses very well, which greatly reduces the number of bytes sent to the client. To enable compression in IIS, access the Internet Services Manager plug-in for the Microsoft Management Console. You can do this by entering inetmgr in the run dialog in the start menu. Right-click the Web Sites folder and select Properties. Options for enabling static and dynamic content are on the Services tab. There is CPU cost associated with compression, so you may want to enable it only for static content if the dynamic content is not cacheable (since the static content is always cacheable, it can be compressed once and not repeatedly).
Another technique for reducing the size of script is variable substitution. You will see this referred to as script compression. The approach is to replace variable names with short versions. When writing code, it is nice to have meaningful names, but because the script engine doesn’t care about this, smaller names also work fine. Tools are available that will take script and do this replacement for you. However, it can make debugging difficult, as the variable names and even function names can be replaced with short, meaningless versions. It may seem like reducing the size of the script doesn’t buy you much, and for a single page load, the difference will be small. But when you look at the effect it can have on the server, there is a big benefit. Smaller scripts can be returned faster. The connections and threads used to service the request are freed up sooner, so a single server can scale to accommodate more simultaneous users.
for(var i=0, var l = someArray.length; i < l; i++) is faster than for(var i=0; i < someArray.length; i++).
The second version caches a reference to the appendChild function and then invokes it directly. This saves the overhead of repeatedly resolving the function name to the actual function call. When multiple scopes and namespaces are involved, the performance advantage is increased.