My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MinifyHtml  
Describes the Minify HTML rule
Updated Nov 23, 2010 by mdste...@google.com

Minify HTML

This rule is currently still experimental, as there are a number of difficulties with minifying HTML:

  • Comments can generally be removed from HTML, but some tools may rely on certain special comments being present in the HTML. Page Speed's HTML compactor recognizes and preserves certain classes of important comments, but may unwittingly remove others that should not be removed. If you encounter such a case, please file a bug.
  • Whitespace between tags can generally be collapsed, except within whitespace-significant blocks. Page Speed's HTML compactor will avoid collapsing whitespace within, for example, <pre> tags, but currently it may still incorrectly remove whitespace from other blocks that use CSS rules to make whitespace significant.
  • Many HTML pages are generated dynamically, in which case the minified HTML file produced by Page Speed cannot simply be used as a drop-in replacement. However, you may, for example, want to use fragments of the minified HTML within a template used to generate the page.
Comment by lebosstom, Feb 15, 2010

Other HTML tags are optional such as </li> </p> </body> </head>. Plus, it would be great to have more information about how browser handle those "optional" tags, and what are the minify rules.

Comment by djth...@gmail.com, Apr 16, 2010

Tell us minify rules, please!!! Cus we need to minify HTML by server on the fly!

Comment by garzon.l...@gmail.com, Apr 30, 2010

I'm appalled that a Google-sponsored product suggests sloppy html syntax, ditching closing tags... If anything, minify should remove all newlines. In fact, my minified version starts with a blank line: way to give away a byte for no reason!

Comment by rokclim...@gmail.com, Oct 7, 2010

I am curious if this rule should still be applied in page speed if compression is enabled. The majority of savings comes from removing unnecessary whitespace, which compression already does very well (and on-the-fly).

Please consider updating the page speed rules to take this into consideration (such as assigning a higher minification score if server compression is done).

Comment by jfbo...@gmail.com, Oct 10, 2010

the minifier removing <!DOCTYPE HTML> makes the page failed validation @ W3c and @ http://html5.validator.nu

Comment by mag...@online.no, Oct 13, 2010

One might save speed from downloading fewer bytes, but all user agents will use additional resources when parsing a html file which does not follow the specified standard. The user agents will use CPU power and memory to "guess" and try and correct the document. How much resource overhead is added to the processing of invalid html varies between the different user agents. This makes it difficult to compare the benefit of removing those few bytes. In addition the different user agents has different error handling resulting in an unpredictable appearance and behavior.

For now everyone should avoid using the optimized HTML generated from Google Page-speed and use valid html.

Comment by nevermor...@gmail.com, Oct 31, 2010
Comment by fleshgri...@gmail.com, Nov 14, 2010

There is a bug in the Google page-speed minification algorithm. Inline CSS is expanded. See this webpage for example and have a look at the page-speed output http://bobdo.com

This page is minified to the maximum that is possible and is perfectly valid. As all of you can see, it is possible to minify the HTML of a page. But you have to use HTML5 to get best minification. Because other doctypes have a lot of overhead per specification.

Comment by vgstou...@gmail.com, Dec 14, 2010

mm-test

Comment by austin.c...@travelocity.com, Feb 25, 2011

Any doctype of HTML can be minified accurately without harm to regression. Visit http://prettydiff.com/ to see how any flavor of markup can be minified and then beautified back countless times without loss of fidelity.

Comment by airticke...@gmail.com, Mar 1, 2011

me testing for my website http://www.airtickettown.com

Comment by audvare, Mar 16, 2011

Minify by NEVER outputting \n in your code. It's that simple. And remove any useless spaces.

Stay well-formed too. Remember that HTML5 does NOT require /> on tags like <meta> (but XHTML does). For non-XHTML, you can just use >. Clean up empty tags that have no purpose.

To me this is definitely NOT about outputting as little as possible and just ensuring the browser works that way.

Comment by mkin...@gmail.com, Apr 12, 2011

How can I improve my site http://www.vividostudio.com ?

Comment by markoz...@gmail.com, May 24, 2011

One question...

Why should you minfy your HTML if you can use gzip compression on the server? Compressing the page using gzip is not a demanding process regarding all other thing that are happening on the server.

Has anyone made any tests how much do you gain/loose in performance (both in file size and server processing) when you use html minification rather than gzip compression?

Comment by killadom...@gmail.com, May 25, 2011

Hope someone can help me with my site: http://killerdomains.com.au/ I have compressed js files, css files etc. However, I think I'll wait till I minify html, as the home page is php file.

My question is also, how to use cache correctly. What about those using Joomla based sights that are able to configure the cache in the backend to store files on the server instead? Google page speed doesn't seem to pick that up???

Comment by SirReal....@gmail.com, Aug 4, 2011

I really like Google's Page Speed Online, but it doesn't appear to offer HTML compression. Aside from using the HTML compression tool that comes in Page Speed browser add ons, is there anywhere online that allows us to use Google's HTML compression tool?

Comment by pocksh...@gmail.com, Sep 13, 2011

<html> <head> <title> </title> </head>

<body>

<ul type=square> <li> item </li> <li> item </li> <li> item </li> <li> item </li> </ul>

<ol start=40> <li> item</li> <li> item</li> <li> item</li> <li> item</li> </ol>

<ol type=A start=13> <li> item</li> <li> item</li> <li> item</li> <li> item</li> </ol>

<ol type=I> <li> item</li> <li> item</li> <li> item</li> <li> item</li> </ol>

<ol type=I start=100> <li> item</li> <li> item</li> <li> item</li> <li> item</li> </ol>

</body>

</html>

Comment by hotelmur...@gmail.com, Jan 1, 2012

I stil search the rule to speed up my site http://www.hotelmurahdibandungs.com

Comment by off...@naturheilpraxis-hubbauer.de, Mar 22, 2012

Does it make sense to work on this issue with following Stats?

"You could save 728B (8%)" http://www.repertorium-online.de

Comment by vitroyfe...@gmail.com, May 2, 2012

i will reduce js, css and hnlt http://kerjawa.blogspot.com/

Comment by eddysupr...@gmail.com, Yesterday (30 hours ago)

http://www.mobilbekas.co.id has many css and javascript in order to increase the display performance and experiance.


Sign in to add a comment
Powered by Google Project Hosting