It has to be accessible in the global scope somewhere. For example:
// file1.js
function hello() {
alert("Hello, world!");
}
// file2.js
$(function() {
hello();
});
Likely, you have something like this:
// file1.js
$(function() {
function hello() {
alert("Hello, world!");
}
// ...
});
// file2.js
$(function() {
hello();
});
hello is only in scope of the closure defined in file1.js. Therefore, to access it in file2.js, you'd have to export it to somewhere where file2.js can get at it:
// file1.js
$(function() {
function hello() {
alert("Hello, world!");
}
window.hello=hello;
});
// file2.js
$(function() {
hello();
});
Also, the script where the function is defined must be loaded, parsed, and executed before the function can be called from another script.