• Welcome to Valhalla Legends Archive.
 
Main Menu

Comments

Started by Grok, April 27, 2004, 10:40 AM

Previous topic - Next topic

Grok

Is there a way to put comments in an HTML page that do not get sent by the web server to the client?

synth

If you were using ASP on that page, you could put them inside ASP tags.

Like so:

<%
' This code was written by me.
%>

Then continue with the rest of your page.  The comment would be visible to you (and to anyone else who has the source), but to the average user, it's invisible.

That's the only way I know of effectively hiding anything from "View Source".

Are you able to use ASP in your pages, or will this be a completely static web page?

Grok

I'm not trying to hide anything from view source.  I want to put comments in my javascript but without the bandwidth penalty of transmitting them to the client.

hismajesty

#3
Is <!-- comment --> what you're looking for?

Edit: Nevermind, re-read your post. I overlooked the part about *not* sending it to the end user.

iago

As far as I know about how html works, the server reads the file and sends the whole thing without caring.  It's possible that certain webservers have extensions to do special things, I would recommend you look at the documentation for the specific webserver you're using.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


quasi-modo

#5
In asp or asp.net
<% 'comment %> would not send to the client. This was mentioned above by synth, what would be the problem with this solution? You can obviously mod the file types that are running on your server and end up with pages that have a .html extention but have server side scripts being executed when they are requested, the draw back is that doing this will mean that all html pages will have to be read by the server. It is going to be different to change extentions on apache iis and other servers though, but it could easily be found by doing a google.
<?php 
// I am not a php user, but this is what a single line php comment looks like
?>
WAR EAGLE!
Quote(00:04:08) zdv17: yeah i quit doing that stuff cause it jacked up the power bill too much
(00:04:19) nick is a turtle: Right now im not paying the power bill though
(00:04:33) nick is a turtle: if i had to pay the electric bill
(00:04:47) nick is a turtle: id hibernate when i go to class
(00:04:57) nick is a turtle: or at least when i go to sleep
(00:08:50) zdv17: hibernating in class is cool.. esp. when you leave a drool puddle

MyndFyre

#6
If you really want to get creative, I would suggest something like this...

Set your ASP interpreter (assuming IIS) to also handle .jsx files.  In any Javascript files you want to comment in, do something along the lines of...


<% @LANGUAGE="JScript" %>
function doStuff()
{

}
<%
// comments go here that won't be sent to the client
// they must be commented, or the ASP interpreter will try to do something with them.
%>
function doMoreStuff()
{
 doStuff();
}


Then set your code to:


<script language="JavaScript" src="MyJavascript.jsx" />


Also, you don't need to worry about bandwidth so much if you have caching enabled on your server and you put your Javascript into a separate .js file.  Then, the server only transmits your code once until it is updated.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

synth

#7

<%
' Comment
%>


This would not transmitted to the client.  Remember that the server executes the ASP code and leaves all code inbetween ASP tags out, and also that compilers, in general, discard comments.  

Therefore, the comment would be left out of the source.  Obviously, it is hidden from view, but more importantly, it is not transmitted to the client, therefore no bandwidth is used.

EDIT: But, if you're set on JavaScript, you could try Myndfyre's solution.

Banana fanna fo fanna

If using CF...

<!--- notice the three dashes --->

Grok

Thanks guys, but I already know how to do it in ASP.  My question was HTML.  But it seems the answer is that no server-side processing is performed on HTML pages without extensions.

quasi-modo

Quote from: Grok on April 27, 2004, 09:42 PM
Thanks guys, but I already know how to do it in ASP.  My question was HTML.  But it seems the answer is that no server-side processing is performed on HTML pages without extensions.
yep, the only way to keep that html format with server side processing is to have the server reguard html files as asp files by changeing the extentions. I am not actually sure how to do it on iis.... hold on.  Humm I thought it could be done when I play around under the headers tab but this doesnt seem to be working... poo.
WAR EAGLE!
Quote(00:04:08) zdv17: yeah i quit doing that stuff cause it jacked up the power bill too much
(00:04:19) nick is a turtle: Right now im not paying the power bill though
(00:04:33) nick is a turtle: if i had to pay the electric bill
(00:04:47) nick is a turtle: id hibernate when i go to class
(00:04:57) nick is a turtle: or at least when i go to sleep
(00:08:50) zdv17: hibernating in class is cool.. esp. when you leave a drool puddle

Adron

Quote from: Grok on April 27, 2004, 09:42 PM
Thanks guys, but I already know how to do it in ASP.  My question was HTML.  But it seems the answer is that no server-side processing is performed on HTML pages without extensions.

You can select to do server-side processing on HTML pages and have shtml. There you might be able to insert some text like this:

<!--#echo tag="LAST_MODIFIED" comment="Try inserting some text here and see if the server accepts the line anyway without passing the comment to the client!" -->