How to Minify Your WordPress Site’s HTML

Disclosure: This post may contain affiliate links. Purchasing a product through one of these links generates a commission for us at no additional expense to you.

Let’s get on the same page.

If you’re reading this post, you probably already know minifying your HTML can speed up your site. It’s a small gain, but then again, most performance improvements are minor.

Just like minifying CSS or JS files, minifying your HTML can easily be automated once and forgotten about.

There are two plugins you should consider to minify your WordPress site’s HTML.

Minify HTML

This straightforward plugin does exactly what it says – it minifies your HTML.

Minify HTML

Minify HTML has very positive reviews from users for being so simple and effective. While it’s a simple plugin, it does have a handful of options to personalize the configuration for your site.

Here’s a screenshot of the settings page from the developer:

Minify HTML Settings

The default settings should work fine for your site, and as always, clear your cache after activating the plugin and visit a few pages to ensure there are no errors.

While that plugin works great, you may want some extra firepower to further enhance your site’s performance.

WP Rocket

I use the WP Rocket plugin to minify the HTML of

WP Rocket

WP Rocket comes with premium-quality caching and tons of other easy-to-use performance optimization tools. You can see how it can be used to optimize CSS delivery and more in our complete WP Rocket Guide.

The HTML minification itself is extremely simple. All you have to do is check off this box in the settings:

WP Rocket Minify HTML

Now you have two easy approaches available to minify your site’s HTML.

Why minify your HTML?

In case you’re not 100% sure what minifying HTML really does and why it works, here’s a quick explanation.

When developers write code, they use indentations to create visual structure in the code. This makes it easier for them to read without impacting how the code works. They’ll also leave comments in the code to explain bits of functionality here and there making the code even easier for themselves and others to understand.

While indenting code and leaving comments are both good practices, our computers don’t need them. The comments take up extra bytes and even the spaces themselves contribute to a larger file size.

Since no one needs to read and edit your site’s source code, it doesn’t need to be easy to read, so we can remove all the comments and spaces. That’s what minification does – it removes all the spaces and comments to make the file smaller leading to slightly faster load times.


HTML minification isn’t likely to have a huge impact on your load times, but it is a very easy tactic to implement which is why it’s commonly recommended.

For a very simple implementation, install the Minify HTML plugin. If you want an equally simple plugin, but with more additional performance features, try WP Rocket.

Ben Sibley
Ben Sibley
This article was written by Ben Sibley. He is a WordPress theme designer & developer, and founder of Compete Themes.