A small and simple to use function, that allows loading scripts atop of promises. The main point of using it is to reduce code repetition and also promise operations (chaining, joining, racing, etc) over script loading.
Obviously the first step is to include our main file, PromiseLoader.js on your HTML:
<script src="./PromiseLoader.js"></script>
Having our script loader avaliable, we can use it in a pretty straight-foward way:
PromiseLoad('your_script.js');
As any JS project, this one also brings some flexibility in its use.
The url of the script to be loaded.
If the script tag will be added to the document head element.
Defaults to true.
Plain object containing additional attributes for the script tag.
A Promise instance that resolves to the script's onLoad event. In case of error the promise will be rejected and reject to the script's onError event.