[thelist] ASP to populate .js file?

Ken Schaefer ken at adOpenStatic.com
Wed Apr 7 10:54:26 CDT 2004


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Stephen Caudill" <SCaudill at municode.com>
Subject: RE: [thelist] ASP to populate .js file?



:: Or alternatively, if I rename the file.js to file.asp, and then
:: do some SQL queries from there, will it still function as a
:: JavaScript file?
:
: Assuming you're talking ASP 3.0 not .NET:  Yes, you'll want to
: change the ext to .asp.  I use filename_js.asp as a convention.
: Use Response.AddHeader before your output starts:
: <%
: Response.AddHeader "Content-type", "application/x-javascript"
: %>
: //followed by JS code, or ASP that outputs JS code.
:
: Maximillian Von Schwanekamp
: NeptuneWebworks.com
: voice: 541-302-1438
: fax: 208-730-6504

Or even better, use the FileSystemObject[1] to open the .js file
as a stream, use ASP to generate your JavaScript, and write this
to the .js file.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I disagree. Unless you get some kind of performance benefit from being able
to cache a static version of the .js file (by persisting it to disk), the
method suggested (creating .js files physically) will be slower than
building the .js on the fly.

On the other hand, if you have a lot of requests for single versions of the
.js file, then the performance benefits of persisting the content to a
static .js file would make this method a no brainer.

Cheers
Ken

Cheers
Ken



More information about the thelist mailing list