Skip to content

the-linck/promise_loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Promise Loader

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.

Using the loader

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');

Parameters

As any JS project, this one also brings some flexibility in its use.

Src  String

The url of the script to be loaded.

Head  Boolean (Optional)

If the script tag will be added to the document head element.
Defaults to true.

Attributes  Object<String, String> (Optional)

Plain object containing additional attributes for the script tag.

Returns  Promise<Event>

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.

About

Small function to load script tags with promises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published