Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/joutvhu/libjs-loader
- Owner: joutvhu
- License: mit
- Created: 2022-08-23T19:17:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-28T07:01:05.000Z (over 1 year ago)
- Last Synced: 2024-09-16T11:47:58.689Z (4 months ago)
- Topics: js, lazy, library, loader
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/libjs-loader
- Size: 248 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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');
...
});
```