Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First let me bottom line your specific example. A series of <code>Response.Write</code> calls just carrying plain string literals is going to be slower than including the complete HTML as content outside of the script code.</p> <p>This idea of "context switching" is a bit of a fallacy as a result of some unfortunate wording in some documentation (or perhaps history). We tend to think of an ASP file as being HTML with some script interspresed in it using <code>&lt;% script here %&gt;</code>. In fact ASP file is a <strong>script</strong> file with some HTML in it. Its easier to reason on what its going if you think of it as having html content separated using <code>%&gt; content here &lt;%</code> (with an implied <code>&gt;%</code> and <code>&lt;%</code> at the start and end of the file). </p> <p>When the file is parsed to p-code a file entirely processable by the script engine is created (there is no "context switching"). In effect <code>%&gt; .... &lt;%</code> becomes a special form of Response.Write that sends the content between the <code>%&gt;&lt;%</code> to the buffer. The difference is that the bytes come verbatim as they appear in the original ASP file whereas the standard <code>Response.Write</code> accepts a Unicode string from VBScript and then has to encode to the <code>Response.CodePage</code> a set of bytes to put in the buffer.</p> <p>Hence the "context switching" is really just the number of times the script has to write to the buffer. Having many <code>&lt;% = someExpression %&gt;</code> in your HTML creates a large number of buffer writes.</p> <p>These days unless you are generating an insanely large amount HTML (the article Doozer mentions is 10 years old) you would have buffering turned on. The cost of many writes is quite low. Reducing them can help but one has to remember that the way VBScript handles string contactenation is not without its problems too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload