tiny-loader

2.0.0 • Public • Published

tiny, dependency-free JavaScript loader — intended primarily for loading polyfills or common libraries up front

loadScripts(["foo.js", "bar.js", "baz.js"], function() {
    // all aforementioned scripts have been loaded
});

(scripts are loaded and executed sequentially)

you can also pass an object in order to assign arbitrary attributes to the generated script tag, e.g. for Subresource Integrity:

loadScripts([{
    src: "https://cdn.example.org/lib.js",
    integrity: "sha256-Ijl…1bE=",
    crossorigin: "anonymous"
}]);

prompted by Loading Polyfills Only When Needed, which explains why document.write should be avoided

see samples directory for usage examples

Readme

Keywords

none

Package Sidebar

Install

npm i tiny-loader

Weekly Downloads

35

Version

2.0.0

License

Apache-2.0

Unpacked Size

6.79 kB

Total Files

13

Last publish

Collaborators

  • fnd