"But, rather than moan and complain, look beyond the issue and strive for the solution. In each problem lies an opportunity to make better, to resolve, or to commence positive change." Byron Pulsifer
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:
This entry was posted on 01 Dec 2009, 20:25 and is filed under Tricks. You can follow any responses to this entry through RSS 2.0.
You can skip to the end and leave a response. Pinging is currently not allowed.
Be careful of SKIP_COMMENTS
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
This entry was posted on 01 Dec 2009, 20:25 and is filed under Tricks. You can follow any responses to this entry through RSS 2.0. You can skip to the end and leave a response. Pinging is currently not allowed.