Is there any way to include contents of a file inside of another with javascript?
<p>My code looks like this:</p>

<pre><code>function submitHandler($link, $modal, close) {
    var ...
    var onDone = function (json, textStatus, XMLHttpRequest) {
     ...
    }
    var onFail = function (XMLHttpRequest, textStatus, errorThrown) {
     ...
    }
    var successModal = function (json) {
    ...
    }
    var failModal = function (json) {
       ...
    }
    if (!$form.get(0).checkValidity || $form.get(0).checkValidity()) {
    ...
        $.ajax({
        ....
            .done(onDone)
            .fail(onFail);
    }
}
</code></pre>

<p>All my related functions are together in the same file. I previously had the functions in different files but then I found out that it seemed better if they were in one file so they could share the same variables (at the top of the file). Is this the coding practice most people use or do they put each javascript function in its own file?  Is there any way to include contents of a file inside of another ?</p>
