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: 3 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 (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-28T07:01:05.000Z (almost 2 years ago)
- Last Synced: 2025-04-18T02:45:07.903Z (3 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
- Code of conduct: CODE_OF_CONDUCT.md
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');
...
});
```