Package Exports
- @filestack/loader
- @filestack/loader/dist/index.esm.js
- @filestack/loader/dist/index.js
- @filestack/loader/dist/module/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@filestack/loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Dependency free js async script loader for browsers maintained by @Filestack
Installation
npm install @filestack/loader
Usage
Loading JavaScript Modules
To load async modules just call method loadModule
import { loadModule } from '@filestack/loader';
loadModule('module-id', 'url/to/b.js').then((b) => {
b.helloWorld();
});
You can register some metadata after module will be loaded with register module
import { registerModule } from '@filestack/loader';
const api = {
helloWorld() {
console.log('Hello world!');
},
};
// Module need to "tell" the loader that it's loaded and ready.
registerModule('module-id', api, { version: 123 });
Loading CSS
import { loadCss } from '@filestack/loader';
loadCss('url/to/style.css').then(() => {
console.log('Style loaded!');
});
Development
Setup
npm install
Testing
Unit
npm test
This command opens in the browser semi-manual tests. Those tests don't have watch, so you need to refire the command with each change.