Intro

On this page I want to throw some links to solder site-level JavaScript includes. Some of the code is old and embarassing (like the pictures of me in really short shorts). However, archiving it here may prevent future repeat work and future broken code.

A rule of thumb with code is to keep the scope as small as possible. That way if the code changes or breaks, then it affects a smaller scope. That said, I confess that over the years I have written code at a larger scope than I have needed to. Shame on me! In my defense, the temptation to code a larger scope is high because programmers are "intelligently" lazy and we don't like to repeat work. However, even worse than repeating work is broken code.

Here are some JavaScript scopes for perspective:

  • In-line.
  • Page.
  • Directory.
  • Site.
  • Library used on multiple-sites.
  • The JavaScript language itself.

If the code does the same thing whether it's client-side or server-side, then name it the same thing. In mixed environments, it is hard to debug code that has prototyped on global objects like String or Date, hence I prefer to make stand alone functions or prototype onto my own objects.

Client-Side JavaScript

The first line of these files is usually something like this depending on the development environment: //<script language="javascript"> //To temporarily view this JavaScript file in some development environments, comment out this line..

Server-Side JavaScript for ASP

The first line of these file is usually something like this depending on the development environment: <% %><% //To temporarily view this ASP page as pure JavaScrpt in UltraEdit, comment out this line. Similarly for VisualStudio, temporarily add the ASP Processing Directive.. The last line of these files is usually something like this: %>.

I used to include the ASP processing directive and lines like the following in my server-side include, but then I lost the option to vary those things depending on the page.

Response.Buffer = true;
Response.CacheControl = "no-cache";
Response.Expires = -1;
Response.AddHeader("Pragma", "no-cache");


GeorgeHernandez.comSome rights reserved