I was surfing the web, as usual and I wanted to take a look at Bing's source code because I was curious and wanted to know what they were using to make their image fade in. I was surprised by what could only be qualified by the following line :
Holy wall of text!
And it made me wonder if there is any advantage to obfuscate your (X)HTML, CSS and JavaScript like this? To reduce the size of the file perhaps?
Edit : After looking around, I realized this was a pretty common practice. Never looked at it from a minification point of view before!
They are not obfuscating. They are minifying in order to reduce the bandwidth used by the millions of requests they see each day.
The goal of JavaScript and CSS minification is always to preserve the operational qualities of the code while reducing its overall byte footprint (both in raw terms and after gzipping, as most JavaScript and CSS served from production web servers is gzipped as part of the HTTP protocol).
You might also be interested in reading the Yahoo! User Interface blog post titled "Minification v. Obfuscation".
2 main reasons to obfuscate your code:
Reduce the total size of the file (like you mentioned) If you replace a function called 'CallThisFunctionAndReturnAnArray' with 'C' - you've saved a lot of characters in your file.
Protect intellectual property - while if this is realistic is definite debatable, this is common justification for doing so. You can get around this with good tools, or if you are just really smart.
File size would certain be a benefit, so much that for example Gmail itself not only does that but also zip its contents.
There is absolutely an advantage to this. There is something important to note, though. There is no reason to actually code like this. Rather, after you are finished doing something (and writing in good readable form), use a minifier to remove unneeded white-space and such. For larger files this can greatly decrease load times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With