[thelist] Javascript or ASP? AND Tip: CF Boolean Evaluation

Joshua Olson joshua at alphashop.net
Thu Sep 20 09:42:32 CDT 2001


----- Original Message -----
From: "Pete Freitag" <pf at cfdev.com>
Subject: RE: [thelist] Javascript or ASP?


: I'd have to agree with Ray here (Server Side), This isn't a complex
: computation for the server to perform, so I don't think your saving much
: server load.  Even the slowest processors these days can execute millions
of
: instructions per second.  Sending lots of unnecessary data to the client
is
: potential much more slower, as far as total response time on the client.
:
: If I had more time I'd run a test, but I think you would find the server
: side would win the battle.

My own personal approach would be to run server side as well, to which I'd
add a way to have clients submit new items for inspection by me and later
addition to the list.  Yummy.

Janet, the server side approach has a few variants to consider.
1) use a database accessible by the server to drive the quote
2) compile all the quotes into a static array within the ASP page and select
one at random
3) compile the quotes into a text file (one per line), and read the file
into a server variable (array) and select one at random from that variable

Each method has its own benefits.  1 is the most difficult to setup
depending on your fluency with the database, corporate red-tape, and server
capabilities.  The benefits of using a db to drive it would ultimately
win-out as far as the range of features you could eventually work into it.

2 is the easiest to implement and for you to maintain the quotes.  However,
is you be nearly impossible to hand off the task of maintaining the list of
quotes to a non-computer savvy individual.

3 is middle ground.  It is fairly straightforward to implement and it is a
very simple matter to make a shortcut to the text file for someone else in
the company to update the list of quotes--one per line.  You could even
automate the process of the updating the server variable by checking the
timestamp on the file... if it's newer than the one recorded last time you
read the file, re-read the file.

If you stick to JS, your best approach would be to create the quotes in a JS
array, offload the code into an include file, and link it into the page.
The function you call would select an index in the array and
document.write() the quote to the page.  The downside is very similar to #2
above... easy for you to maintain, tough to delegate.

As far as the speed issues that have been posted, they really should be
negligible once you consider page caching in the browser and the size of the
included file.  If you have 50 quotes at 512 bytes a piece, then the total
is only 25k.  At 100mbps intranet speed... very fast.

HTH,

-joshua

<tip type="ColdFusion">
More of a "did you know this?" than anything else.

If you set

<cfset test = "yes"> or <cfset text = "true">

Then

<cfif test IS "1"> evaluates to true.

and if you set

<cfset test = "no"> or <cfset text = "false">

Then

<cfif test IS "0"> evaluates to true.

But the other way doesn't work.  eg, if you set

<cfset test = "1">

Then

<cfif test IS "no"> and <cfif test IS "false"> evaluate to false;

</tip>






More information about the thelist mailing list