In the early days, we used to hide JavaScript code from old browsers that do not support JavaScript.
The way of doing this was to put a one-line HTML-style comment without the closing characters immediately after the opening <script> tag and put //--> at the end of the script.
However if you are using this trick with the initialization parameter facelets.SKIP_COMMENTS set to true, the code between <!-- and //--> won’t even be sent to the client!
It simply means that the code above won’t open an alert window because it has been skipped during the page rendering.
Set the SKIP_COMMENTS parameter to false (the default is true). This can’t really hurt, your page will just be heavier depending on how much HTML comments you put on your page;
No need to hide the JavaScript code as all browsers are now supporting it and over 99.9% of users have it enabled – this is the solution I chose.
For information, below is the code to put in your web.xml file to set the SKIP_COMMENTS parameter to false:
Be careful of SKIP_COMMENTS
Posted by smoreau in Tricks on 01 Dec 2009
In the early days, we used to hide JavaScript code from old browsers that do not support JavaScript.
The way of doing this was to put a one-line HTML-style comment without the closing characters immediately after the opening
<script>
tag and put//-->
at the end of the script.For example:
However if you are using this trick with the initialization parameter
facelets.SKIP_COMMENTS
set to true, the code between<!--
and//-->
won’t even be sent to the client!It simply means that the code above won’t open an alert window because it has been skipped during the page rendering.
Here is what the client will receive:
You have two solutions to avoid this situation:
SKIP_COMMENTS
parameter to false (the default is true). This can’t really hurt, your page will just be heavier depending on how much HTML comments you put on your page;For information, below is the code to put in your web.xml file to set the
SKIP_COMMENTS
parameter to false:Facelets, JavaScript, old browsers, SKIP_COMMENTS
No Comments