Skip to content

Commit e459c8e

Browse files
committed
Deprecate manual brotli decompression
It doesn't have much benefit but comes with a maintenance cost as we either need to keep patching upstream's js implementation for use in JSO — which also bloats binary size by including two copies of brotli and its default dict — or use the C implemntation from JS which requires boilerplate in both C and JS and also additional JS polyfills to keep e.g. the fontname extraction working. The browser's in-built support for Content-Encoding is more felxible, faster and simpler to use.
1 parent 8db03e5 commit e459c8e

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,16 @@ simply will not draw anything in canvas, mostly on low end devices.
175175
**WARNING: Experimental, not stable and not working in some browsers**
176176

177177

178-
### Brotli Compressed Subtitles
179-
The SubtitleOctopus allow the use of compressed subtitles in brotli format,
180-
saving bandwidth and reducing library startup time
181-
182-
To use, just run: `brotli subFile.ass` and use the .br result file with the subUrl option
178+
### Brotli Compressed Subtitles (DEPRECATED)
179+
Manual support for brotli-compressed subtitles is tentatively deprecated
180+
and may be removed with the next release.
181+
182+
Instead use HTTP's `Content-Encoding:` header to transmit files compressed and
183+
let the browser handle decompression before it reaches JSO. This supports more
184+
compression algorithms and is likely faster.
185+
Do not use a `.br` file extension if you use `Content-Ecoding:` as this will
186+
conflict with the still existing manual support which tries to decompress any data
187+
with a `.br` extension.
183188

184189
## How to build?
185190

src/pre-worker.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ function isBrotliFile(url) {
4545
len = url.length;
4646
}
4747

48-
return url.endsWith(".br", len);
48+
if (url.endsWith(".br", len)) {
49+
console.warn("Support for manual brotli decompression is tentatively deprecated and "
50+
+ "may be removed with the next release. Instead use HTTP's Content-Encoding.")
51+
return true;
52+
}
53+
54+
return false;
4955
}
5056

5157
Module = Module || {};

0 commit comments

Comments
 (0)