# Add html/php minification

**URL:** https://discourse.roots.io/t/add-html-php-minification/4545
**Category:** sage
**Created:** 2015-08-22T09:12:09Z
**Posts:** 11

## Post 1 by @dandin84 — 2015-08-22T09:12:09Z

hi, i would like to add html/php minification to sage for higher google pagespeed rank. where will you advise me to start from?

---

## Post 2 by @ben — 2015-08-22T16:41:24Z

HTML/PHP minification isn’t related to your WordPress theme. I’d advise you to start looking at plugins that accomplish what you want.

[https://wordpress.org/plugins/search.php?q=html+minify](https://wordpress.org/plugins/search.php?q=html+minify)

---

## Post 3 by @dandin84 — 2015-08-22T18:45:09Z

thank for your answer,

i am trying to avoid using plugin for this because they usually make other problems from my experience.

i kind of succeed to minify with grunt: grunt-contrib-htmlmin in a scratch theme i built.

i hoped maybe i could do it here too… but from my digging i didn’t find a gulp task that can handle php files so i pass for now…

thanks anyway

---

## Post 4 by @ben — 2015-08-22T18:52:59Z

You could also use a CDN like Cloudflare to handle the minification.

You definitely don’t want to have something in your theme’s build script responsible for the HTML minification of your whole site.

---

## Post 5 by @dandin84 — 2015-08-22T18:57:46Z

do you think it will remove the error on pagespeed insight about html minification?

---

## Post 6 by @ben — 2015-08-22T19:00:58Z

Considering they specifically offer HTML minification, I don’t see why not?

> **[How do I minify HTML, CSS and JavaScript to optimize my site?](https://support.cloudflare.com/hc/en-us/articles/200168196-How-do-I-minify-HTML-CSS-and-JavaScript-to-optimize-my-site-)**
>
> Cloudflare users interested in minifying HTML, CSS and JavaScript can activate Auto Minify in their Cloudflare settings. Auto Minify will remove all unnecessary characters from HTML, JavaScript, an...

---

## Post 7 by @dandin84 — 2015-08-22T19:58:29Z

thanks a lot, i will check it…

---

## Post 8 by @jessuppi — 2018-10-25T00:57:21Z

Old thread but still relevant, as CloudFlare minify no longer does much of anything.

If interested check out our new Minify HTML plugin for WordPress (works also with Sage theme):

> **[Minify HTML](https://wordpress.org/plugins/minify-html-littlebizzy/)**
>
> Tactfully minifies HTML output and markup to remove line breaks, whitespace, comments, and other code bloat to cleanup source code and improve speed.

Several defined constants to customize functionality, no settings/database.

---

## Post 9 by @dandin84 — 2018-10-25T03:55:51Z

Looking great, thanks jessuppi!

---

## Post 10 by @codepuncher — 2018-10-26T06:59:08Z

Purchase WP Rocket. Best one I’ve used and requires minimal configuration.

---

## Post 11 by @dandin84 — 2018-11-09T14:15:47Z

Thanks codepuncher,

Its really looks promising, I will recommend it to my client.
