Dan
Dan

Reputation: 905

Do conditional include files affect ASP performance?

In (classic) ASP, when include files are used, but effectively redundant because they fall inside an IF statement - how do these redundant include files impact on performance?

For example

<%
If Condition(1) or GlobalCondition Then %><!--#INCLUDE FILE="PageX.asp" --><% End If
If Condition(2) or GlobalCondition Then %><!--#INCLUDE FILE="PageY.asp" --><% End If
%>

There can be tens of unused include files. Some include files are just libraries of functions but many files are largely HTML content with simple server-side code.

Upvotes: 1

Views: 1821

Answers (3)

Metalcoder
Metalcoder

Reputation: 2262

The #include's are processed before the code; so no if/else logic will be executed at include time. In your code, both PageX.asp and PageY.asp will be included, regardless of the conditions.

For more info, you can check this.

Upvotes: 2

Erik Oosterwaal
Erik Oosterwaal

Reputation: 4384

Consider using WSC's. They behave like COM components, but can be written in vbscript. You can give them properties and methods. They can also be included conditionally, and aren't always loaded, unlike INC files:

http://aspalliance.com/414_Windows_Scripting_Components_WSC_in_ASP

One more tip: you don't have to (re)register the WSC like the article says, you can call/include a WSC file without registering it like so:

GetObject("script:"&Server.MapPath("/path/to/component.wsc"))

HTH,

Erik

Upvotes: 2

RobV
RobV

Reputation: 28655

Well the way <!--#include file="page.asp"--> works in ASP is that it is effectively pulling the contents of that file into one chunk of code and then compiling it before executing it. The code in your includes should only really affect compilation performance and not execution performance.

Despite that if your application is structured like this I'd seriously consider reworking it somewhat though that may not be an option for you.

Upvotes: 3

Related Questions