Including other .js files from javascript

  • Thread starter Catherine Lynn Smith
  • Start date
C

Catherine Lynn Smith

I am trying to figure out the recommended way to include javascript
'from' javascript. I found some references that say to just write a
'script' tag to the document, but I am curious about the parse order
for this.

i.e., if I have a 'core set' of routines that I prefer to store in a
seperate file due to the fact they are used in multiple pages, it
makes more sense to call them in from the javascript that needs them,
but if I do so with a 'write' to the document, are they parsed before
any additional code in the existing .js file?

The idea being - since these would be core functionality routine
libraries, the page-specific code I include via the HTML will need to
have any subroutines and functions available to work properly.

Any help and comments are greaty appreciated.

KL
 
C

Catherine Lynn Smith

OK, an addendum to my earlier post/question. I was able to find out
that a document.writeln was sufficient to include files with a
standard HTML script tag including those fulfilling needs of dependant
functions. But this raises another issue now.
Is it going to hurt anything if the file is included twice, or is
there any way to check within the code for the existence of a function
before doing the document.writeln('<script....>') stuff? Or should I
handle this by defining a variable somewhere in the 'library' itself
and testing against that?

KL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top