MyFaces Core provides a feature to minimize the additional white spaces in a HTML page to reduce its size. Usually the code generated by Renderers does not contains unnecessary spaces, but the code that comes directly from HTML markup in facelets comes straight from the xhtml or xml file used.
The trick behind this feature is enable/disable it as a do inside facelets compiler option.
Just add this into your faces-config.xml
file:
<?xml version="1.0"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
<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-extension>
</faces-config>
That's it.
Now, facelets compiler will try to reduce or remove spaces/tabs when they are not necessary, following the rules for HTML white space compression, to avoid change the appearance of the page.
In simple words, this means when necessary it replace multiple continuous spaces with just one or remove all of them. It also try to use '\n' characters when possible, to make easier read the page markup once compressed.
Since this optimization is done in facelets compiler, the effort to reduce white spaces is just done once, so all your pages will not impose additional CPU or memory overhead. So it reduce the memory and CPU resources required to render a page, so this can give a little boost to your application.