Description
Facelets algorithm usually takes almost all spaces in a page and output them directly. The algorithm only trim the spaces on the right, but it doesn't do anything about the spaces/tabs on the left.
Thinking about how to solve this properly, I notice html markup is compiled in a list of Instruction instances, that follows a command pattern to do calls over ResponseWriter. It is possible to use that information and decide when remove all spaces between two elements or when just let one space or line break in between or at the begin/end of the html markup.
This optimization can reduce effectively the amount of information sent to the client with minimal side effects. Anyway, to keep compatibility with the reference implementation (and keep running some tests) we cannot enable this one by default.
The proposal is add an extra element in faces-config file like this:
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<faces-config-extension>
<facelets-processing>
<file-extension>.xhtml</file-extension>
<process-as>xhtml</process-as>
<oam-compress-spaces>true</oam-compress-spaces>
</facelets-processing>
</faces-config>
Suggestions are welcome.