Using comments with WebvantaScript

It is tempting to think that you can stop some WebvantaScript from being executed by surrounding it with HTML comment markup (<!--   -->), but it is important to realize that this doesn't work as you may expect.

Keep in mind how the system works when a page is requested:

  1. The Webvanta server processes the request, creating the page out of all of its component parts, and executing any WebvantaScript. At this point, no HTML is being interpreted, it is just being created.
  2. The browser processes the page as delivered by Webvanta, and it is the browser that interprets the HTML.

So if you have code like:

<!-- <w:snippet name="my-snippet" /> -->

and if the snippet generates the string "This is my snippet"

Then what appears in your page, as delivered to the browser, is:

<!-- "This is my snippet" -->

And since the text is in an HTML comment, the browser won't display it. So it will have the desired effect, in that the result will not appear.

HOWEVER, note that the snippet WAS accessed, the HTML comments are just keeping the browser from doing anything with the results. So if an error occurred in reading that snippet (such as if there is no snippet of that name), Webvanta will encounter an error trying to create the page.

To stop WebvantaScript code from executing, surround it with a <w:comment> tag.

If you use <w:comment><w:snippet name="my-snippet" /></w:comment>, then the snippet will not get accessed at all, because the w:comment tag tells Webvanta to ignore the enclosed WebvantaScript.

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk