Cleaning up my old Drupal 7 code that I don't use anymore and don't feel the need of picking it up for a D9 or D10 port. Feel free to ping me if you want to take over this module

MiniHTML

If you can not install MOD_PAGESPEED or other HTML compressor on webserver level, this module can help you reach a higher score on the speedtest, and eventually a higher pagerank.

The idea is that instead of looping through all the renderable regions to compress the HTML output, I duplicated the drupal_deliver_html_page method and minify the entire HTML output at once.

By enabling this module, you let Drupal to deliver the HTML as needed going trough all the hooks and what not, and follow the exact same pattern as Drupal normally does. The advantage of this approach is that modules like boost, page cache and systems like Varnish can cache the compressed HTML output like they normally do.

At this moment I also minify the inline JS added by modules and code added directly in a template. I did not implement a CSS minify routine, cause I simply do not have the need for that at this moment ;) I will make this configurable later on, as the advagg has a way better and more tunable approach for this.

Compressing the HTML is not the same as gzipping the page, in fact they are complementary to each other. This module collapses all the whitespace on page, like described on the collapse white space filter manual

Example

<html>

  <head>
    <title>Hello,   world!   </title>
    <script> var x = 'Hello,   world!';</script>
  </head>

  <body>
    Hello, World!
    <pre>
      Hello,
        World!
    </pre>
  </body>

</html>

is compressed into something like this.

<html><head><title>Hello,   world!   </title><script> var x = 'Hello,   world!';</script> </head><body>
    Hello, World!
    <pre>
      Hello,
        World!
    </pre>/body></html>

TL;DR This module removes all the whitespace in your HTML except those between TAGS.

Drupal 8 version

As an exercise for my self I've taken upon the task of converting this module to a Drupal 8 version, most likely trying the new HTTP middleware approach (if possible)

Project information

Releases