First, I see that Google suggests minifying everything – – HTML, JS and CSS to increase performance.
But I doubt it does only good, and no bad; especially because many of the popular websites haven’t enabled at least HTML minification (and some haven’t even enabled JS and CSS minification as well).
So, can someone knowledgeable, please enlighten me off the ill-effects / cons of enabling the following on a website:
- HTML minification
- JS minification
-
CSS minification
-
for example, I heard that HTML minification could cause issues with Google analytics and Adsense (or any ad) code in the page. Is it true?
If done right, minification can be completely without side effects. The thing is, it’s not that easy to get things right.
For example, Google’s JS compiler, Closure, generally works fine but breaks more complex scripts. Always a tradeoff, better compression at the cost of less compatibility, or the other way around.
Also, by enabling gzip, you achieve somewhat more compression than minification, all without touching your code. This burns server CPU.
Bottomline is, if you’re not sure you need minificaton — you probably don’t.