yui compressor: minimize your js or css file online
Why do you need to compress Javascript and CSS?
About 40-60% of Yahoo users have an empty cache experience while 20% of all page views are done with an empty cache.
So it is crucial that you keep your webpages as lightweight as possible. This is where the concept of website compression comes in.
The main goal of JavaScript and CSS minification is to maintain the operational qualities of the code. At the same time, it reduces the overall byte footprint.
What is a YUI Compressor?
A YUI compressor is a JavaScript Compressor that removes comments and whitespaces as well as obfuscates local variables using the smallest possible variable name. It also compresses CSS files safely.
Advantages of using YUI Compressor tool
- It’s very easy to use!
- This tool is a JavaScript minifier which guarantees a higher compression ratio compared to other tools.
- It is completely reliable since it doesn’t mess up codes.
- This tool is open-source, so you can always look at the code to understand exactly how it works.
- It performs all kinds of operations to save bytes in a completely safe way!
How Does it Work?
This tool is written in Java and depends on Rhino to tokenize the source JavaScript file. Initially, a YUI compressor analyzes the source JavaScript file in order to understand how it is structured. Afterwards, it prints out the token stream. In the process, many white space characters are omitted as possible. It also replaces all local symbols by a 1 (or 2, or 3) letter symbol wherever a substitution is needed. On the other hand, the CSS compression algorithm utilizes a set of finely tuned regular expression in order to compress the source CSS file.