Forums > MaxMSP

Invoke other javascript files from inside javascript

Sep 30 2009 | 10:37 am


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

Sep 30 2009 | 1:32 pm


I found a way:

globalfunction = function a () {

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

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

Sep 30 2009 | 4:48 pm

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

Sep 30 2009 | 4:55 pm

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.

Viewing 4 posts - 1 through 4 (of 4 total)

Forums > MaxMSP