Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

minifyHtml option in core misleading

0 votes
75 views
asked Dec 16, 2017 in Q2A Core by q2apro

In qa-theme-base.php you find: 

protected $minifyHtml; // (boolean) whether to indent the HTML

"minify" is for me all code compressed. No indents is "no indents". 

I would rather expect a compression when I see the word "minify". 

Suggestion: Rename $minifyHtml to $noIndentHtml

Q2A version: 1.8.0 beta

1 Answer

0 votes
answered Dec 16, 2017 by Scott
selected Dec 17, 2017 by q2apro
 
Best answer

Actually the HTML is minified as much as it can be (or close enough anyway). The problem is, with HTML you can't remove space between tags entirely as it changes the behaviour of the HTML.

Simple example:  <b>Hello</b> <i>World</i>
You can't remove the space between those tags because your text will say "HelloWorld" instead of "Hello World".

The best you can do is collapse all space down to one whitespace character, which is exactly what we do (using newline instead of space). If you look at how other systems work you should find they do the same - I know CloudFlare does.

Incidentally, Q2A's minification also has an extra speed benefit because it actually reduces the processing time on the server. In other words, the actual PHP code in qa-theme-base.php is notably faster if indentation is omitted.

commented Dec 17, 2017 by q2apro
Thanks for the clarification.
...