[Project_owners] JavaScript includes ... ?

Todd Ross todd at brainsick.com
Fri Mar 18 05:49:21 EST 2005

Eric Jung wrote:
> There *is* a native Javascript way to do this, and it works in both
> XUL and HTML. I don't know why you'd bother pulling in a depedency
> like jsLib when you can simply do this:
> XUL or HTML file:
> <script type="application/x-javascript" src="includes.js"></script>
> includes.js:
> document.write("<script type='application/x-javascript'
> src='file1.js'></script>");
> document.write("<script type='application/x-javascript'
> src='file2.js'></script>");
> document.write("<script type='application/x-javascript'
> src='file3.js'></script>");

I guess I wasn't being clear when I used the word native.  I meant "Core 
JavaScript" -- as in, not client-side.  There isn't a document object in 
the Core.

If a year down the road, someone invents jssh (a JavaScript Unix Shell), 
then I'd still like to be able to use my Classes in that environment. 
Philip also mentioned XBL as another instance where something like this 
might be useful.  I don't know if there's a Document object in that 
environment or not.

I'm trying to code *JavaScript* Classes that could potentially be used 
in any environment where JavaScript happens to be embedded.  That 
doesn't seem like a bad goal to have.

Konstantin, I prefer your solution over the document.write above, but it 
runs into the same problems of assuming a Document object.  There's also 
a typo -- fName should be name.


More information about the Project_owners mailing list