CloudFlare Optimization: Enabling CSS, JavaScript, & HTML Minification

A question I see frequently asked on various WordPress forums and groups is whether or not you should enable the minimize HTML, CSS, & JavaScript feature in CloudFlare. I wanted to address this as I often see it answered incorrectly. Some users are told that if they are already serving pre-minified files or already minimizing HTML, CSS, and JavaScript with a plugin such as Autoptimize, that they should avoid enabling this feature in CloudFlare to prevent issues.

I have never followed this rule. I always enable the minimize HTML, CSS, & JavaScript feature in CloudFlare even when the website is already serving pre-minified files. The reason this doesn’t cause any issues is because the CloudFlare minification tool only removes a few instances of white space and comments.

Why would I bother enabling both if XYZ plugin is already doing that, especially if the benefits are minimal? This is a fair point, however let me give you three reasons why you should enable the feature!

Removes HTML Footer Plugin Branding

Some plugins add comments into your site’s HTML. This means they put some sort of branding HTML comment in your footer. This is ultimately annoying and quite pointless. For example, many plugins that are responsible for optimization are also responsible for adding branding in the footer. This is annoying because you are either stuck trying to see if they have a filter to remove it or you have to live with it. CloudFlare’s minification tool removes this.

Removes CSS and JavaScript Comments

Many JavaScript and CSS files have comments kept in them. They says things like “This is Bootstrap” or “This is JQuery,” etc. Many WordPress plugins leave this code in the files. This is fine, but I prefer to keep files as clean as possible. CloudFlare’s minimize HTML, CSS & JavaScript feature takes care of this.

CloudFlare’s optimization features takes care of these issues and keeps your sites files clean. It has never caused any issues for me on sites I have used it on. Albeit, it could be more powerful, but that’s for a future post.

Therefore, yes, you should enable the minimize HTML, CSS, & JavaScript feature in CloudFlare, even if you are already using another tool such as Autoptimize.

If it does cause an issue, you can simply disable the feature in CloudFlare.

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

1 thought on “CloudFlare Optimization: Enabling CSS, JavaScript, & HTML Minification”

Leave a Comment