[Project_owners] JavaScript includes ... ?

Todd Ross mozdev at brainsick.com
Thu Mar 17 16:33:29 EST 2005


Pete Collins wrote:
> Todd Ross wrote:
>> Is there a way to include one JavaScript file inside of another?  CSS 
>> allows you to use the @import directive ... is there a JavaScript 
>> equivalent?
> 
> Sure ...
> 
> jsLib include ()
> 
> Eg:
>  jslib.init(this);
>  include(chrome://mypackage/content/myjsFile.js");
> 
> Install:
>  http://jslib.mozdev.org/installation.html
> 
> Docs:
>  http://jslib.mozdev.org/doc_index.html

The Classes that I'm trying to make are just pure JavaScript and could 
potentially be used on in both HTML and XUL (chrome'd or non-chrome'd). 
  What I'm sensing is that there's no native JavaScript directive to 
import a script from within a script.  That's okay -- it at least 
explains why I couldn't find it.  I can add multiple <script> tags to 
the HTML or XUL -- it's just not ideal.

Speaking of jsLib ... I've always been a bit hesitant to use it because 
of how clunky it is to state dependencies in Firefox.  The jsLib install 
page even says as much.  In the install.rdf, there is a way to identify 
dependencies, but it doesn't look like there's a way to have Firefox 
fetch them and install them.

jsLib works around this by expecting extension developers to include 
code to redirect users to your install package if jsLib isn't already 
installed, but even that seems clunky.  When is the Extension Manager 
going to live up to its potential?

I really long for a CPAN-like repository of JavaScript modules with a 
apt-get-like method of automatically resolving dependencies.  I think 
extension development will really take off if we ever reach a point like 
that.

Todd


More information about the Project_owners mailing list