diff --git a/src/browser/index.js b/src/browser/index.js index c9fd31b66..880515093 100644 --- a/src/browser/index.js +++ b/src/browser/index.js @@ -124,10 +124,11 @@ exports.defaultOptions = { * @param {object} instance - TesseractWorker instance * @param {object} options * @param {string} options.workerPath - worker script path + * @param {boolean} options.workerBlobURL - Use a blob:// URL for the worker script */ -exports.spawnWorker = (instance, { workerPath }) => { +exports.spawnWorker = (instance, { workerPath, workerBlobURL }) => { let worker; - if (Blob && URL) { + if (Blob && URL && workerBlobURL) { const blob = new Blob([`importScripts("${workerPath}");`], { type: 'application/javascript', }); diff --git a/src/common/TesseractWorker.js b/src/common/TesseractWorker.js index 01d50900c..5b66287c3 100644 --- a/src/common/TesseractWorker.js +++ b/src/common/TesseractWorker.js @@ -32,6 +32,7 @@ class TesseractWorker { * In browser-like environment, it is downloaded from a CDN service. * Please update this option if you self-host the worker script. * In Node.js environment, this option is not used as the worker script is in local. + * @param {boolean} [options.workerBlobURL=true] - Use a blob: URL for the worker script * @param {string} options.corePath - * A remote path to load tesseract.js-core script. * In browser-like environment, it is downloaded from a CDN service. diff --git a/src/common/options.js b/src/common/options.js index 36a923919..a86a263de 100644 --- a/src/common/options.js +++ b/src/common/options.js @@ -8,6 +8,10 @@ module.exports = { * of 20 MB. */ langPath: 'https://tessdata.projectnaptha.com/4.0.0', + /* + * Use BlobURL for worker script by default + */ + workerBlobURL: true, }, /* * default params for recognize()