Is it possible to configure JSF 2.0 to remove unnecessary white spaces between XHTML tags?
Is it possible to configure JSF 2.0 to remove unnecessary white spaces between XHTML
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. Facelets cannot distinguish unnecessary whitespace from necessary whitespace. For that it would need to determine individual HTML tags, parse CSS and JS files for any evidence that it is really unnecessary. In case of the HTML
<pre>and<textarea>tags, the CSSwhite-space:preproperty and JSelement.style.whiteSpace='pre'code, the whitespace is namely significant.It’s simply too expensive and complicated to check that reliably. If your actual concern is network bandwidth, then just turn on gzip compression at server level. How to do that depends on the server used, but on Tomcat for example it’s as easy as adding
compression="on"to the<Connector>element in/conf/server.xml.It is however possible to create a
Filterwhich replaces the response writer to trim the whitespace. You can find here an example of such a filter. It only doesn’t take CSS/JS into account.