Skip to content

Commit a31deaa

Browse files
authored
Switched default CDN from unpkg to jsdelivr per #743 (#744)
1 parent 249eade commit a31deaa

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Tesseract.js works with a `<script>` tag via local copy or CDN, with webpack via
102102
### CDN
103103
```html
104104
<!-- v4 -->
105-
<script src='https://unpkg.com/tesseract.js@4.0.2/dist/tesseract.min.js'></script>
105+
<script src='https://cdn.jsdelivr.net/npm/tesseract.js@4/dist/tesseract.min.js'></script>
106106
```
107107
After including the script the `Tesseract` variable will be globally available.
108108

docs/local-installation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ In Node.js environment, the only path you may want to customize is languages/lan
1010

1111
```javascript
1212
Tesseract.recognize(image, langs, {
13-
workerPath: 'https://unpkg.com/tesseract.js@v4.0.3/dist/worker.min.js',
13+
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v4.0.3/dist/worker.min.js',
1414
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
15-
corePath: 'https://unpkg.com/tesseract.js-core@v4.0.3/tesseract-core.wasm.js',
15+
corePath: 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3/tesseract-core.wasm.js',
1616
})
1717
```
1818

1919
Or
2020

2121
```javascript
2222
const worker = await createWorker({
23-
workerPath: 'https://unpkg.com/tesseract.js@v4.0.3/dist/worker.min.js',
23+
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v4.0.3/dist/worker.min.js',
2424
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
25-
corePath: 'https://unpkg.com/tesseract.js-core@v4.0.3/tesseract-core.wasm.js',
25+
corePath: 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3/tesseract-core.wasm.js',
2626
});
2727
```
2828

@@ -33,4 +33,4 @@ A string specifying the location of the `worker.js` file.
3333
A string specifying the location of the tesseract language files, with default value 'https://tessdata.projectnaptha.com/4.0.0'. Language file URLs are calculated according to the formula `langPath + langCode + '.traineddata.gz'`.
3434

3535
### corePath
36-
A string specifying the location of the [tesseract.js-core library](https://github.com/naptha/tesseract.js-core), with default value 'https://unpkg.com/tesseract.js-core@v4.0.3/tesseract-core.wasm.js'.
36+
A string specifying the location of the [tesseract.js-core library](https://github.com/naptha/tesseract.js-core), with default value 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3/tesseract-core.wasm.js'.

src/worker-script/browser/getCore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = async (corePath, res) => {
1111
if (!corePathImport) {
1212
const simdSupport = await simd();
1313
if (simdSupport) {
14-
corePathImport = `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core-simd.wasm.js`;
14+
corePathImport = `https://cdn.jsdelivr.net/npm/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core-simd.wasm.js`;
1515
} else {
16-
corePathImport = `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core.wasm.js`;
16+
corePathImport = `https://cdn.jsdelivr.net/npm/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core.wasm.js`;
1717
}
1818
}
1919

src/worker/browser/defaultOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
...defaultOptions,
1010
workerPath: (typeof process !== 'undefined' && process.env.TESS_ENV === 'development')
1111
? resolveURL(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`)
12-
: `https://unpkg.com/tesseract.js@v${version}/dist/worker.min.js`,
12+
: `https://cdn.jsdelivr.net/npm/tesseract.js@v${version}/dist/worker.min.js`,
1313
/*
1414
* If browser doesn't support WebAssembly,
1515
* load ASM version instead

0 commit comments

Comments
 (0)