See "About This JavaScript Site" in JavaScript Index and Introduction.
As with other pages, the date of the page is independent of the dates of the include files shown.
Where code is common to more than one Web page, it is effective to put it into one or more "include" files, so that only one copy needs to be maintained and transmitted.
With an invocation such as
the contents of the file include2.js are treated as if the above had been
An include file can contain functions, declarations, and other statements; but not overt HTML. Here is a representation of my complete include2.js (used only in JavaScript Tests, and below) as a trivial example (the comments are not necessary) :-
Often, the include statements will be placed at or near the top of a Web page, in the HEAD or BODY section.
Extension .js is commonly used, but has the disadvantage when used in the URL of a link that the file may then be treated as a Windows executable.
If a required include file is missing, code needing it will fail, perhaps confusingly. After invoking, I test by code like :-
In fact, I check variables defined at each end of the file, since it is possible for a file to be only partially up/down-loaded.
In a <script ... > part, if the type attribute is not set, the previous value is used; the default is JavaScript. The only other type I actually know much of is VBScript.
I have read that adding defer="defer" in the script tag allows page parsing to continue, since the included file code does not invoke any writes.
Code to select an include file can be written into a page while it is loading, but the contents must not be used until the file has loaded - or so it seems.
More elegantly, see Bart Van der Donck in news:c.l.j 2008-03-25.
Disused JavaScript routines are coded in include0.js.
General JavaScript routines are coded in include1.js, including the routines used to display in boxes with coloured borders.
A test variable is declared in include2.js.
General JavaScript date routines are coded in include3.js, and widely used in my pages.
Other include files are specific to my Rounding, Zeller, and other Easter pages.
The include files may also define a few variables.
My code can be used as code (where the boxes do not suffice, try View Source, in the page or on a browser menu), but should not be re-published.
Display of code, and parts of this page, require JavaScript.
Microsoft Internet Explorer (4-7, +?) and Google Chrome display functions and methods as written, in the original layout and complete with comment. If your browser does not (e.g. Firefox, Opera, Safari), you should resort to View Source or an independent viewer.
Read "Code Display on This Site" in Index and Introduction, and page Code Boxes. For the coding of the double-bordered boxes, see ShoFFF() etc. under "Code Display" in the include1.js section of this page.
Simple Functions are shown in full. Added Methods may be shown as function anonymous with their names following in comment.
Some supplementary Methods may be conditionally defined; if you already have them, [native code] will be shown.
Functions Caption. contain identifying comment, and are functions merely in order that the comment can be shown.
Some routines, particularly date ones, have limited range :-
I no longer use this include file or these functions elsewhere.
See in Rounding 1
Across this site, Name Used The Function Return SigFigNum NumDecSigFig Number SigFigFxd StrSigFigFxd String '#.#' SigFigExp StrSigFigExp String '#.#e#'
Current routines, self-shown by ShoFFF(ShoFFF, ... , 0, "-- ... :", ...) :-
Display code in a new window :-
See at Link Markings.
OK?
MJD 0 = 1858-11-17 GMT, CMJD 0 = 1858-11-17 local;
MJD 40587 = 1970-01-01 GMT = JavaScript day 0.
See at Day Counts.
Functions with "zu" are faster, for me, but may have smaller range.
UK HMRC Tax : from YYYY-04-06
For The Calendrical Works of Rektor Chr. Zeller : The Day-of-Week and Easter and associated pages.