Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

enableWorker: true does not by itself mean hls.js is using a Web Worker. In the ESM build, hls.mjs, the transmuxer worker is a separate asset: you must configure workerPath to point to the matching deployed hls.worker.js. Without that path, transmuxing runs on the main thread. The UMD build handles this differently because its worker is inlined.

Why enableWorker may not be enough

The API documentation lists enableWorker as true by default and workerPath as null. These settings do different jobs: enableWorker enables worker use when available, while workerPath tells the ESM build where to find its separate worker file. With no usable worker path in an ESM setup, transmuxing stays on the main thread.

The worker is used for transport-stream (TS) demuxing and MP4 remuxing. It does not mean that all playback, network loading, or media decoding moves off the main thread. The documented aims include better performance and fewer playback lags or dropped frames, but the project documentation does not promise a particular improvement or provide a benchmark figure. The hls.js API documentation describes the options and their defaults.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check which hls.js build your app uses

First identify the artifact that your deployed application actually loads. A source-level import is not conclusive: bundlers may resolve the ESM distribution, and the migration guide notes that bundlers such as webpack are likely to select ESM by default.

  • ESM (hls.mjs): The worker is not bundled into this distribution. The app needs a separately served hls.worker.js and a valid workerPath.
  • UMD: The README says the worker is inlined, so the separate-worker-path issue specific to ESM does not apply in the same way.

The migration guide identifies the ESM distribution and its workerPath requirement as part of hls.js 1.4. For older or pinned releases, check the documentation and files for the exact version your application deploys rather than assuming current master documentation describes it. See the hls.js migration guide and README distribution notes.

Configure the worker path for ESM

Set workerPath to a URL your application can serve, using the worker asset that matches the hls.js version in use. The README gives this CDN URL as an example, not a universal deployment requirement:

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
const hls = new Hls({
  workerPath: 'https://cdn.jsdelivr.net/npm/hls.js@1/dist/hls.worker.js',
});

In production, ensure the worker URL resolves to the intended asset and that it stays version-aligned with the library. A configuration value only shows what the app intends to use; it does not establish that the deployed file loaded or that a worker started.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify worker use in the deployed page

  1. Inspect the resolved build. Confirm whether the deployed bundle includes or resolves to the ESM or UMD distribution. Check the built output rather than inferring the artifact from source imports alone.
  2. Check the runtime configuration. For ESM, inspect the hls.js configuration and confirm that workerPath points to the deployed hls.worker.js for the same version.
  3. Observe the browser runtime. Use browser developer tools to look for a worker target and a successful load of the worker asset. Tool labels and views vary; report what you actually observe rather than treating the configuration setting as proof.
  4. Check the relevant playback work. Worker use here concerns TS demuxing and MP4 remuxing. Do not conclude that every part of playback runs in a worker simply because the worker asset loaded.

What to check when transmuxing remains on the main thread

  • The app resolved ESM: Configure workerPath; the ESM file does not bundle the transmuxer worker.
  • The path is set but the asset did not load: Check that the URL is reachable from the deployed page and points to the correct worker file. A set path is not evidence of a successful load.
  • The asset loaded but versions differ: Align the worker file with the hls.js package version deployed by the app.
  • The app uses UMD: Its worker is inlined according to the README, so do not apply the ESM external-file diagnosis without first confirming the selected build.
  • You need to assess performance: Observe the app under its actual playback workload. The documentation states intended benefits, not a guaranteed speedup or a universal performance ranking.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.