Synchronously importing JavaScript - how to throw errors properly
<p>I use this to import scripts inside of a js file. However, sometimes these scripts have errors and they require the script that they are being imported into in order to work. Unfortunately, if there is an error in the script, the error thrown is just "Could not load script scriptName", instead of logging the error in console.</p>

<pre><code>/* Synchronously import scripts */
var require = function (script, callback) {
    $.ajax({
        url: script,
        dataType: "script",
        async: false,
        success: function () {
            if(callback) {
                callback();
            }
        },
        error: function () {
            throw new Error("Could not load script " + script);
        }
    });
}
</code></pre>

<p>Any help is greatly appreciated.</p>
