Invoke other javascript files from inside javascript

Sep 30, 2009 at 10:37am

Invoke other javascript files from inside javascript

Hi

I’d like to create a library of functions/objects inside JS which I can re-use whereever I want in my other Scripts.
I know there is no easy #inlcude “aLibFile.js” command from inside js, but perhaps Max is providing another solution for that?
In HTML and PHP you can easyily include other js-files.

Thanks for your help in advance

#45666
Sep 30, 2009 at 1:32pm

Hi

I found a way:

globalfunction = function a () {
post(“globalfunctionn”);
}

this you can put into your lib.js.
load the lib.js somewhere and call this function inside aother js like
a();
and it works.

but still: including js-files would be more appreciative.

#164695
Sep 30, 2009 at 4:48pm

JavaScript doesn’t have anything like the include’s C or the require in ruby for instance. If you put some files in the js-etensions folder though you are kinda able to emulate that behavior. Note that you’ll have to restart Max each time you change the files in there. There are a few examples included in the standard distribution, ejies does that as well if you need more examples.

BTW, there’s a dedicated JS forum Wink

#164696
Sep 30, 2009 at 4:55pm

thanks for the help

I know there are zounds of boards, but I was hoping Max included something for this case in it’s js-framework which I have overseen.

#164697

You must be logged in to reply to this topic.