Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joutvhu/libjs-loader

Provides a method for lazy loading of JS libraries in the browser.
https://github.com/joutvhu/libjs-loader

js lazy library loader

Last synced: 2 months ago
JSON representation

Provides a method for lazy loading of JS libraries in the browser.

Awesome Lists containing this project

README

        

# LibJs Loader

Provides a method for lazy loading of js libraries in the browser.

## Installation

```shell
npm i libjs-loader
```

## Using

```ts
import { loadLibrary } from 'libjs-loader';

loadLibrary(
'https://mozilla.github.io/pdf.js/build/pdf.js',
'pdfjs-dist/build/pdf',
(pdfLib: any) => {
const pdfWorker = 'https://mozilla.github.io/pdf.js/build/pdf.worker.js';
pdfLib.GlobalWorkerOptions.workerSrc = pdfWorker;
pdfLib.loadScript(pdfWorker);
})
.then(pdf => {
const loadingTask = pdf.getDocument('pdf url');
...
});
```