7dr3am7
7dr3am7

Reputation: 765

Loading JS file with JS without a web page

I have been researching for a simple solution to a problem that I have.

I have a JavaScript file that needs to use some functions that are contained in another JS file. I read many posts from stack overflow, and they all require a to be loaded from a web page. In my case they absolutely do not use a web page to be loaded and I do not want to use one.

The reason is because I am running JavaScript unit testing from command line using Rhino. Please I'm begging for help!

Upvotes: 0

Views: 104

Answers (2)

Dagg Nabbit
Dagg Nabbit

Reputation: 76736

Use Rhino's load function (about a third of the way down this page): https://developer.mozilla.org/en/Rhino_Shell

Upvotes: 1

duncan
duncan

Reputation: 31912

You can load in the other javascript file using Ajax. Have a look at jQuery .getScript(). I'm not sure if that'll work in the context of running from the command line, or if it just appends the .js file to the document.body.

Upvotes: 1

Related Questions