You need to sign in to do that
Don't have an account?
Server side comments
Hey guys,
Am I right by concluding that VisualForce pages do not have server side comments?
Something from the Java (JSP pages) world would be <%-- my comment --%> or <% /* some comment */ %>
This is very different from an HTML comment such as <!-- comment --> by the fact that the client still has to download what's ever in it.
I have found this old thread:
Which concluded with no asnwer, tried to google but was unsuccessful.
If I use the <!-- --> syntax VisualForce just masks whatever characters are in those comment tags.
This is still a problem because I do not want the client to download junk.
Is there a way to make server side comments? If not, then maybe a hack to wrap the comment in some custom apex block element?
Below is what I see in the HTML source using the <!-- --> syntax:
<!-- ***************************************** ********************** ****************************** *********************************************************************************** ** ********** ****** ****************************************************************************************** *********************************************************************************** ****** ******************************************** ************************************************************** ******************************************** ******************************* ************** ****************************************************** ************************************************************************** ****************************************************************************** ************************** ******************** ******* ******** ************ ********************************* ***************************************** ******************************************************************************* **************************************************************************** *************************************************************************************** ************************************* ************************** ******************** ******** ******* *************************************** ******************************************* **************************************************************************** *************************************************************************************** ************************************* ******* ****************** ******* ***** **** *** ****** *-->
Thank you!
Nope, you can't make server-side comments that won't be downloaded as masked characters. Before you worry too much about that, you should consider that salesforce.com connections are gzipped, and they'll compress down to absolutely nothing (not literally, but so small you won't notice). Besides, a typical SFDC page is almost 2 MB of uncompressed data, so the extra bytes won't really matter in the grand scheme of things.
All Answers
Nope, you can't make server-side comments that won't be downloaded as masked characters. Before you worry too much about that, you should consider that salesforce.com connections are gzipped, and they'll compress down to absolutely nothing (not literally, but so small you won't notice). Besides, a typical SFDC page is almost 2 MB of uncompressed data, so the extra bytes won't really matter in the grand scheme of things.
Ok so I found a small hack for this...
You can do this...
You can also make it a component and do something like this in you VS pages:
Nice hack. It certainly does work, since you're then not hiding comments directly. You could also use any Visualforce elements that accepts text and has the rendered attribute, as far as that goes... apex:outputPanel, apex:outputLabel, apex:outputText, apex:pageBlock, and most other visual elements behave this way. The only problem with this workaround is that one would be cluttering the code unnecessarily, as most IDEs won't syntax-highlight them as actual comments, etc. That aside, I'm surprised I didn't think of it sooner myself...
All your points are absolutely valid and I totally agree with all of them. The problem I was trying to solve, and maybe I should of explained the context first, is hidding unminified JS and CSS. The app will have quite a bit of JS and CSS going forward and we don't want to waste HTTP requests to get these resources. What I am doing is breaking JS namespaces into components (like JSPF static includes) and then minify each but keeping the unminified version commented out for easy developement.
Either way, problem solved! :)
Thanks for your help