By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,968 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,968 IT Pros & Developers. It's quick & easy.

Including other .js files from javascript

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.