1.0.0 • Published 2 years ago

libjs-loader v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

LibJs Loader

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

Using

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');
        ...
    });