Response.Write vs <%= %>

后端 未结 15 2670
我在风中等你
我在风中等你 2020-12-28 14:34

Bearing in mind this is for classic asp

Which is better, all HTML contained within Response.Write Statements or inserting variables into HTML via &l

15条回答
  •  执笔经年
    2020-12-28 14:46

    My classic ASP is rusty, but:

    Response.Write "" & vbCrlf
    Response.Write "" &vbCrLf
    Response.Write "" & someVariable & "" & vbCrLf 
    Response.Write "" & vbCrLf 
    Response.Write "
    " & vbCrLf

    this is run as-is. This, however:

    <%= someVariable %>

    results in:

    Response.Write"\r\n\r\n\r\n\r\n
    " Response.Write someVariable Response.Write "
    "

    Where \r\n is a vbCrLf

    So technically, the second one is quicker. HOWEVER, the difference would be measured in single milliseconds, so I wouldn't worry about it. I'd be more concerned that the top one is pretty much unmaintainable (esp by a HTML-UI developer), where as the second one is trivial to maintain.

    props to @Euro Micelli - maintenance is the key (which is also why languages like Ruby, Python, and in the past (tho still....) C# and Java kicked butt over C, C++ and Assembly- humans could maintain the code, which is way more important than shaving a few ms off a page load.

    Of course, C/C++ etc have their place.... but this isn't it. :)

提交回复
热议问题