# @filestack/loader

> Dependency free js async script loader for browsers maintained by @Filestack

Latest version **1.0.9** (published 2021-03-25) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @filestack/loader
pnpm add @filestack/loader
yarn add @filestack/loader
bun add @filestack/loader
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2021-03-25 |
| First published | 2020-03-19 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 124.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | PCholuj |
| Maintainers | filestack-admin, pcholuj, filestack-dev |

## Links

- npm: https://www.npmjs.com/package/@filestack/loader
- Repository: https://github.com/filestack/filestack-loader-js
- Issues: https://github.com/filestack/filestack-loader-js/issues
- npm.io page: https://npm.io/package/@filestack/loader

## Recent versions

- 1.0.9 (latest) — 2021-03-25
- 2.0.0-beta.0 (beta) — 2024-11-22
- 1.0.8 — 2020-10-05
- 1.0.7 — 2020-03-25
- 1.0.6 — 2020-03-25
- 1.0.5 — 2020-03-25
- 1.0.4 — 2020-03-19
- 1.0.3 — 2020-03-19
- 1.0.2 — 2020-03-19
- 1.0.1 — 2020-03-19

## README

<p align="center">
  <a href="https://www.filestack.com"><img src="https://static.filestackapi.com/filestack-js.svg?refresh" align="center" width="250" /></a>  
</p>
<p align="center">
  <strong>Dependency free js async script loader for browsers maintained by @Filestack</strong>
</p>

## Installation

```
npm install @filestack/loader
```

## Usage

### Loading JavaScript Modules

To load async modules just call method loadModule

```js
import { loadModule } from '@filestack/loader';

loadModule('module-id', 'url/to/b.js').then((b) => {
  b.helloWorld();
});
```

```js
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

```js
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.

---
_Source: https://npm.io/package/@filestack/loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
