flipzoom / ProcessWire-AIOM-All-In-One-Minify

AIOM+ (All In One Minify) is a ProcessWire module to easily improve the performance of your website. By a simple function call Stylesheets, LESS and Javascript files can be parsed, minimized and combined into one single file. This reduces the server requests, loading time and minimizes the traffic. In addition, the generated HTML source code can be minimized and all generated files can be loaded over a cookieless domain (domain sharding).
MIT License
33 stars 26 forks source link

HTML minify removes space character between HTML tags #40

Open Toutouwai opened 9 years ago

Toutouwai commented 9 years ago

I have a script like this:

echo "<p><strong>Label:<strong> <span>Text</span></p>"

The space between the <strong> and the <span> tags is deliberate and should be preserved as a literal space character in the paragraph. But when the "HTML minify" option is on the space character between these tags is stripped out. The same problem occurs if I have an <a> tag after my <strong> tag.

Toutouwai commented 9 years ago

Just saw this:

NOTE: AIOM+ removes all whitespaces between two tags. If you explicitly need a whitespace, change the whitespace into an HTML entity: &nbsp;.

This doesn't seem like an adequate solution to me. A non-breaking space is not the same as a space - I want my lines to be able to break at the space character.

Would be nice if HTML minify was smart enough to work out when a literal space character is intended between tags. Looking at a couple of other HTML minify tools, the preserving of these kinds of spaces happens by default or can be enabled through an option. http://www.willpeavy.com/minifier/ http://kangax.github.io/html-minifier/ https://code.google.com/p/htmlcompressor/ Perhaps single spaces between tags could be preserved while multiple spaces are replaced by a single space?

phocks commented 6 years ago

Just had the same problem. I think tags in paragraphs should definitely retain their surrounding spaces because often you are "selecting" specific words within the paragraph and then when the HTML is minified it bunches those words together. Not desirable behaviour at all.

matjazpotocnik commented 6 years ago

@phocks try this version (requires php>=7.0.0): https://github.com/matjazpotocnik/ProcessWire-AIOM-All-In-One-Minify/