Updated November 2026: hls.js v1.7.4 (28 October 2026), native HLS in Chrome 142 and the new README fallback rule, an hls.js error reference table, and CDN and hls.min.js install notes.

What is hls.js? The short answer

hls.js is a free, open-source JavaScript library that plays HLS (HTTP Live Streaming) video in web browsers that do not play HLS natively. It downloads the .m3u8 playlist and the media segments, converts them into a format the browser can decode, and feeds them to the <video> element through the browser's Media Source Extensions (MSE) API. It is released under the Apache 2.0 license, has no user interface of its own, and plays HLS only (no MPEG-DASH). As of November 2026 the current version is v1.7.4 (28 October 2026), and the npm package was downloaded 14,796,794 times in the week of 9–15 November 2026 (npm registry).

Use hls.js when you need adaptive HLS playback in Chrome, Edge, Firefox or a smart-TV web runtime; on Apple devices you can either use it or hand the playlist straight to Safari's native player. Install it with npm install hls.js or load it from a CDN with <script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>, as the official README shows. Seeing an hls.js error in the console? Jump to the error reference table further down.

hls.min.js is the file that CDN line serves: the minified UMD build in the package's dist/ folder, which exposes a global Hls and inlines the transmuxer worker. For v1.7.4 it is about 624 KB minified and about 190 KB gzipped; hls.light.min.js (about 389 KB) leaves out alternate audio, subtitles, EME, CMCD and Interstitials (jsDelivr and README, checked 16 November 2026). In production, pin the exact version, for example https://cdn.jsdelivr.net/npm/hls.js@1.7.4/dist/hls.min.js, so a new release cannot change your player overnight. The ESM build (hls.mjs) does not inline the worker; set workerPath to dist/hls.worker.js or transmuxing runs on the main thread.

hls.js at a glance (November 2026)Answer
Latest stable versionv1.7.4, 28 October 2026; last 1.6 patch is v1.6.19 (19 August 2026)
LicenseApache 2.0, free for commercial use
Official homegithub.com/video-dev/hls.js (about 17.1k stars) and the hls.js package on npm
BrowsersAny browser with MSE: Chrome, Edge, Firefox, Opera, desktop Safari 10+; iPadOS 13+; iPhone Safari 17.1+ through Managed Media Source (since hls.js v1.5.0)
Install and CDNnpm install hls.js; or cdn.jsdelivr.net/npm/hls.js@1, which serves dist/hls.min.js (global Hls)
Native HLS elsewhereSafari plays HLS natively; desktop Chrome and Edge do since version 142 (late 2025), but the README still recommends Hls.isSupported() first
ProtocolsHLS and LL-HLS only; for DASH use dash.js or Shaka Player
DRMWidevine, PlayReady and FairPlay through EME with fMP4 segments; DRM over MPEG-2 TS is not supported
Newer HLS featuresInterstitials, content steering, HEVC in MPEG-2 TS (v1.6, March 2025); I-frame trick play and CMCD v2 (v1.7, August 2026)

Why this matters

If you ship video to a browser, mobile web, or smart-TV web runtime in 2026, hls.js is almost certainly already in your bundle, or it should be. Apple's Safari plays HLS natively, desktop Chrome and Edge only started to in late 2025, and none of the native players give you one ABR, one event stream and one error model across every browser. After reading this article, a product manager should be able to ask an engineer the right questions about adaptive bitrate behaviour, error recovery and DRM scope. A frontend or smart-TV engineer should come away with a complete mental model of the library: the controllers that compose it, the events that feed a production telemetry pipeline, the config knobs that change ABR behaviour without forking the code, and the five error types (with four recovery paths) you have to handle on day one. You do not need prior streaming knowledge; the core terms are defined when they appear. By the end you will also know why low-latency HLS is already on by default in hls.js and which two settings decide whether you actually get a 3-second live experience.

What hls.js is, and what it is not

In one sentence: hls.js is a JavaScript library that reads an HLS playlist, fetches the video chunks it points to, repackages them on the fly into a format the browser can decode, hands those bytes to the browser's Media Source Extensions API, and exposes an event stream rich enough to drive an entire production player UI on top, all from inside an open-source, Apache 2.0-licensed package you npm install like any other dependency. It ships no UI: no buttons, no skin, no tap targets. It does not transcode; every byte it sends to the browser was already encoded by your packager. And hls.js plays HLS only; for DASH you reach for Shaka Player or dash.js. The README (master branch, November 2026) now opens with one line: "HLS.js is a JavaScript library that implements an HTTP Live Streaming client" (video-dev/hls.js, README, accessed 2026-11-16). It then says the client relies on MSE, or on Managed Media Source where MSE is missing, and that sentence sums up the product.

The library is built on top of two W3C standards that, together, took roughly a decade to ship across all major browsers. The first is Media Source Extensions (W3C, Media Source Extensions™, Recommendation 17 November 2016; the second edition, Media Source Extensions 2, is still a Working Draft (latest 9 November 2026) and adds the ManagedMediaSource interface), which lets JavaScript append arbitrary video and audio bytes into a SourceBuffer attached to a <video> element. The second is Encrypted Media Extensions (W3C, Encrypted Media Extensions, Recommendation 18 September 2017), which gives JavaScript a sandboxed way to negotiate decryption keys with the browser's Content Decryption Module. Without MSE there is no way to feed segmented video into a <video> element from JavaScript; without EME there is no way to play paid premium content. hls.js connects those two browser-side APIs to the HLS protocol, defined by IETF RFC 8216 (HTTP Live Streaming, August 2017) and extended by the second-edition draft (draft-pantos-hls-rfc8216bis-22, May 2026) and Apple's HLS Authoring Specification for Apple Devices.

Two columns comparing the two paths to HLS playback in a browser. The left column, Safari on iOS and macOS, is the native path: AVFoundation plays the HLS URL with no library. An HLS origin or CDN holding master.m3u8, media.m3u8 and segment.ts or segment.m4s feeds AVFoundation in the OS, which parses the playlist, fetches segments, demuxes, decrypts with FairPlay and decodes in hardware, and that feeds a video tag with src set to master.m3u8, with no library in the bundle. An aside headed Why only Apple notes that AVFoundation has parsed m3u8 since 2009 while Blink and Gecko never shipped an HLS demuxer, so MSE had to carry it. The right column, Chrome, Edge, Firefox and Opera, is the hls.js path, where the library bridges HLS to Media Source Extensions: the same HLS origin or CDN feeds the hls.js loader with its xhrSetup and fetchSetup hooks, retries, timeouts and byte range; then a transmuxer in a worker repackages MPEG-2 TS as fMP4 off the main thread; then the MSE SourceBuffer, whose appendBuffer() feeds bytes the browser can decode; then the video element, where the browser decoder paints it. Both columns close with feature detection: canPlayType for mpegurl answers probably on Safari, and Hls.isSupported() is true wherever MSE or Managed Media Source exists, which today includes desktop Safari and iPhone Safari 17.1 and later. A final line says to ship both branches, because feature detection picks the right path in one line. Figure 1. The two paths to HLS playback in a browser. Safari can use the native path; every other browser needs hls.js.

You can confirm this with one line in a fresh tab: Hls.isSupported() returns true wherever the browser exposes MSE or Apple's Managed Media Source: Chrome, Edge, Firefox and Opera, and also desktop Safari, iPadOS Safari and iPhone Safari on iOS 17.1 or later. It returns false only where neither API exists, such as iPhones on iOS 16 and older and some legacy TV browsers; there you fall back to the native <video> tag. The official README recommends checking Hls.isSupported() first, because canPlayType('application/vnd.apple.mpegurl') can answer "maybe" in browsers that do not play HLS reliably. Many teams still choose the native path on Apple devices on purpose: AVFoundation decodes in hardware and gives you AirPlay and system Picture in Picture for free. Our iOS native video player guide compares the two paths on iPhone.

Why this library exists at all

HLS was invented by Apple, ratified by Apple, and shipped first on Apple devices. Apple Safari plays HLS natively because AVFoundation, the macOS and iOS media framework, has known how to parse .m3u8 playlists and .ts segments since 2009. The other engines, Blink (Chrome, Edge, Opera) and Gecko (Firefox), chose not to ship a built-in HLS demuxer, both because the protocol was perceived as Apple-controlled and because the MSE API was designed precisely so any JavaScript library could implement any streaming protocol the application needed. That left a gap on the open web: an industry-standard streaming protocol that worked on iPhone out of the box and nowhere else.

That changed only in late 2025. Chrome 141 began rolling out a built-in HLS player on desktop, Chrome 142 turned it on by default, and Chromium-based Edge 142 shipped it too (Tech-ish, 8 December 2025). Chrome 141.0.7390.123 and later had a bug that raised HLS playback errors between 23 October and 5 November 2025, and Mux's advice to players such as hls.js was to prefer MSE playback (Mux status page, incident of 23 October 2025). In November 2026 the hls.js README still recommends calling Hls.isSupported() first, because Chrome reports native HLS support yet can fail on some assets.

hls.js was created by Guillaume du Pontavice at Dailymotion in 2015 to fill that gap. The early goal was modest: parse the HLS manifest, fetch the MPEG-2 Transport Stream segments, transmux them to fragmented MP4 (which MSE accepts), and append the bytes into a SourceBuffer. Over the next eleven years the library accumulated controllers (ABR, buffer, EME, audio track, subtitle track, content steering, interstitials, I-frame playback) and grew into the de facto cross-browser HLS player. Rob Walch is the lead maintainer, with contributors from across the streaming industry. The GitHub repo had about 17.1k stars and 2.8k forks in November 2026, and the npm package recorded 14,796,794 downloads in the week of 9–15 November 2026 (npm registry, hls.js, accessed 2026-11-16). The README's "They use HLS.js in production" list includes Dailymotion, JW Player, Mux, Akamai, Kaltura, The New York Times, TED, ZDF and Canal+.

The politics matter because they shape the roadmap. hls.js follows Apple's spec for HLS features: when Apple adds a feature to the HLS Authoring Specification (interstitials, content steering, Pathway Cloning, HEVC over MPEG-2 TS), hls.js follows. When the hls.js maintainers add something Apple has not (request retry heuristics, ABR tuning knobs, error recovery surfaces), it adds it as configuration and stays within the spec. The library has no opinion of its own about HLS and implements Apple's in the browsers Apple does not control.

The architecture in one paragraph

A running hls.js instance is a small graph of objects that hang off the top-level Hls class. The Hls constructor wires up the controllers and connects them to each other through a single in-process event bus: a stream controller that runs the segment-fetch state machine, a level controller that owns the multi-variant playlist, an ABR controller that picks the next variant, a buffer controller that owns the MSE SourceBuffer objects, an EME controller that talks to the browser's CDM when DRM is in play, a loader subsystem that does the HTTP fetches, and a transmuxer worker that converts MPEG-2 TS segments to fMP4. You call hls.attachMedia(video) to bind the instance to a <video> element, then hls.loadSource(url) to start fetching the playlist, then listen for events to drive your UI. Everything else is configuration.

The hls.js controller graph, drawn as controllers around one event bus. The input side, which fetches, selects and parses, holds five boxes: the stream controller, on the hot path, running the segment state machine through IDLE, FRAG_LOADING, PARSING and APPENDING; the level controller, which owns the multivariant playlist and live reload on a schedule; the ABR controller, which uses a throughput EWMA and a safety factor of 0.7 before an upshift; the loader, with xhrSetup and fetchSetup, retries and timeouts; and the transmuxer worker, which turns MPEG-2 TS into fMP4 through PES, NAL, moof and mdat. Arrows from all five run down into the event bus, a full-width band showing hls.on(Hls.Events.MANIFEST_PARSED, () => video.play()) and the events FRAG_LOADED, LEVEL_SWITCHED, BUFFER_APPENDED and ERROR. Arrows run from the bus down to the output side, which appends, decrypts and renders: the buffer controller with the MSE SourceBuffer, its append queue and hole tolerance; the EME controller handling Widevine, FairPlay and PlayReady licences; the audio track controller with multiple renditions and mid-stream switching; the subtitle controller for WebVTT and CEA-608/708 cue rendering; and interstitials, reading EXT-X-DATERANGE from version 1.6 and SCTE-35 cues for ad insertion. A legend marks three kinds of box: standard controller, hot path per segment, and DRM and EME. Figure 2. The hls.js controller graph. Every controller subscribes to events on the bus; almost every public event you listen to in your application is emitted from one of these boxes.

That is the whole architecture. The rest of this article zooms into each box, names the events it emits, and tells you which configuration switches matter.

The stream controller

The stream controller is the core of the library. It owns a small state machine (STOPPED, IDLE, KEY_LOADING, FRAG_LOADING, WAITING_LEVEL, PARSING, PARSED, BUFFER_FLUSHING, ENDED, ERROR) and walks through it once per segment for as long as playback runs. In the simplest run, the machine starts in IDLE, asks the level controller "which variant should I be loading?", transitions to FRAG_LOADING while the loader fetches the segment, transitions to PARSING when the bytes arrive and the transmuxer starts converting MPEG-2 TS to fMP4, transitions to PARSED when the conversion finishes, hands the bytes to the buffer controller for append, and returns to IDLE to do the next segment. When DRM is involved it pauses in KEY_LOADING while the EME controller fetches a license. When it has to flush buffered media, for example after a seek or a forced quality switch, it passes through BUFFER_FLUSHING. When the stream ends it transitions to ENDED. When anything fails it transitions to ERROR and emits an Hls.Events.ERROR event.

The states matter in practice. Every event you listen to in production (FRAG_LOADED, LEVEL_LOADED, BUFFER_APPENDED, MANIFEST_PARSED) fires at a specific state transition, and the order is deterministic. If you write a "time to first frame" instrumentation pass over hls.js (you should), you will measure it as the elapsed time between MEDIA_ATTACHING and the first FRAG_BUFFERED for the video SourceBuffer, and that interval lines up exactly with the stream controller walking from STOPPED through PARSED for the first segment.

The level controller and the ABR controller

The level controller owns the multi-variant playlist (.m3u8 with an EXT-X-STREAM-INF tag per variant) and the per-variant media playlists (.m3u8 with a list of EXTINF segments). It fetches the multi-variant once, then refreshes the active variant's media playlist on a schedule for live streams (every target duration) or once for VOD. It exposes the variants to the ABR controller through a levels array.

The ABR controller picks which variant to load next. The algorithm hls.js ships with is a throughput-based heuristic. It tracks the recent download bandwidth using two exponentially weighted moving averages, a fast one and a slow one (half-lives of 3 and 9 seconds by default), and takes the lower, multiplies the estimate by a safety factor (0.95 to stay on or drop to a rung, 0.7 to climb), and picks the highest variant whose declared bitrate is below the safety-adjusted estimate. When the buffer is short or a download is taking longer than expected, the controller can mid-flight abandon the current segment and downshift. The rule is roughly "if fewer than two segments are buffered and the projected download time would deplete the buffer, abort and try a lower variant" (video-dev/hls.js, src/controller/abr-controller.ts, master branch, accessed 2026-10-17). The controller is replaceable: the supported override is to pass your own class in the config: new Hls({ abrController: MyAbrController }).

Two configuration knobs change ABR behaviour without forking code. abrBandWidthFactor (default 0.95) is the safety factor applied to the throughput estimate when picking the next variant during a steady-state run. abrBandWidthUpFactor (default 0.7) is the more conservative safety factor applied when considering an upshift. The asymmetry is intentional: picking too low costs you quality, picking too high costs you a rebuffer, and rebuffers hurt watch time more than a 100 kilobit-per-second quality dip does. v1.7.0 (12 August 2026) adds two more: abrSwitchInterval sets the minimum number of seconds between automatic switches (default 0, off), which dampens the "ABR is flapping between rungs" pattern operators see on jittery cellular networks, and errorPenaltyExpireMs lets a rung that was penalised for a load error be chosen again after a set time. v1.7 also caps the selected rung to the player's on-screen size through ResizeObserver (video-dev/hls.js, Release v1.7.0, 12 August 2026).

hls.js does not ship a buffer-based controller. BOLA (Buffer Occupancy based Lyapunov Algorithm, Spiteri, Urgaonkar and Sitaraman, IEEE INFOCOM 2016) is the buffer-based algorithm you will find in dash.js; in hls.js the default stays throughput-based, and if you want buffer-based or server-driven logic you write it as a custom abrController. A separate Learn article walks the BOLA algorithm in detail and explains when each family wins.

The buffer controller

The buffer controller is a thin layer over the browser's Media Source Extensions API. It creates a MediaSource, attaches it to the video element via URL.createObjectURL, opens one SourceBuffer per media track (typically one video and one audio; subtitles go to text tracks, not MSE), and serialises append, remove, and end-of-stream operations because MSE refuses concurrent operations on a SourceBuffer. It also handles the messy details: appending fragmented MP4 init segments before media segments, computing buffer-hole tolerances during quality switches, and, since v1.7.0, the MEDIA_SOURCE_REQUIRES_RESET error detail, raised when the MediaSource closes while still attached so your app can react before hls.js resets it. The same release adds BUFFER_APPEND_NO_PROGRESS for append cycles that do not grow the buffer and an appendTimeout option (video-dev/hls.js, Release v1.7.0, 12 August 2026).

On iPhone with Safari 17.1 or later, the buffer controller uses the ManagedMediaSource API instead, Apple's power-efficient variant of MSE that is now part of the W3C Media Source Extensions 2 draft. hls.js has used it on iPhone since v1.5.0. ManagedMediaSource is not a drop-in MSE: the browser can evict buffered data on its own and tells the player when to fetch through startstreaming and endstreaming events, and Safari enables it only when remote playback is disabled or an AirPlay alternative, typically a native HLS <source>, is present (WebKit, Features in Safari 17.1). hls.js detects it automatically. v1.7.0 fixed ManagedMediaSource cold starts failing on iOS 26.2, and v1.7.1 added a workaround for startstreaming not firing after a seek. v1.7.4 (28 October 2026) detaches instead of resetting the MediaSource when the video element is switched to another source, and marks a fragment as a gap when its SourceBuffer append fails, so playback skips it instead of looping (video-dev/hls.js, Release v1.7.4). Even so, many teams still prefer the native AVFoundation path on iPhone when the content is plain HLS, because it is hardware-accelerated end to end.

The EME controller

The EME controller handles DRM. When the manifest declares an EXT-X-KEY tag that names a key system (Widevine urn:uuid:edef8ba9-..., FairPlay com.apple.streamingkeydelivery, or PlayReady urn:uuid:9a04f079-...), the EME controller intercepts the stream controller's KEY_LOADING state, calls navigator.requestMediaKeySystemAccess, opens a MediaKeySession, fetches the license from the URL you configured, and feeds the key into the browser's Content Decryption Module. The buffer controller cannot append the encrypted bytes until the key arrives, which is why a slow license server is the most common cause of a black-screen-no-error on a paid stream.

The configuration in modern hls.js (v1.3 and later) lives under drmSystems:

const hls = new Hls({
  emeEnabled: true,
  drmSystems: {
    'com.widevine.alpha':           { licenseUrl: 'https://drm.example.com/widevine'  },
    'com.microsoft.playready':      { licenseUrl: 'https://drm.example.com/playready' },
    'com.apple.fps':                { licenseUrl: 'https://drm.example.com/fairplay',
                                      serverCertificateUrl: 'https://drm.example.com/fairplay/cert' },
  },
});

The older widevineLicenseUrl shortcut still exists but new code should use drmSystems. FairPlay works through standard EME with fMP4 segments; the legacy com.apple.fps.1_0 key system and any DRM over MPEG-2 TS segments are not supported and need native Safari playback (video-dev/hls.js README, accessed 2026-10-17). v1.6.15 (19 November 2025) fixed a FairPlay key-ID patching bug behind "keyId is null" errors, and v1.7.0 (12 August 2026) improved multi-key handling, reads Widevine key IDs from the PSSH when KEYID is missing, and fixed PlayReady key endianness on some devices. v1.7.4 (28 October 2026) reuses attached MediaKeys across loadSource() calls, resets MediaKeys for FairPlay when the MediaSource changes, and adds an experimental reuseKeySessions option (default false) that skips a new license request when a key matches an open session. If you ship multi-DRM, pin v1.7.4, or at least the last 1.6 patch, v1.6.19. For the full EME mental model (what a CDM is, what cenc vs cbcs means, how the license exchange flows end to end), see our Encrypted Media Extensions (EME) deep dive.

The minimal hls.js player

A working hls.js player takes about a dozen lines. This is the canonical pattern:

import Hls from 'hls.js';

const video = document.querySelector('video');
const url   = '/streams/master.m3u8';

if (Hls.isSupported()) {
  const hls = new Hls();
  hls.loadSource(url);
  hls.attachMedia(video);
  hls.on(Hls.Events.MANIFEST_PARSED, () => video.play());
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  // No MSE or Managed Media Source (e.g. iOS 16 and older): native HLS.
  video.src = url;
  video.addEventListener('loadedmetadata', () => video.play());
}

This follows the same order as the official README. Hls.isSupported() checks for MSE or Managed Media Source, not for HLS support, so it is true in every current desktop browser including Safari and on iPhone from iOS 17.1; the canPlayType branch catches older iPhones and TV browsers without MSE. If you would rather use Apple's native player wherever it exists, do not simply test canPlayType first. Since Chrome 142 turned native HLS on, desktop Chrome also answers "maybe", and the README warns that Chrome (it cites version 147) reports support yet can fail on some assets. So the README's alternative setup now goes native only when canPlayType('application/vnd.apple.mpegurl') is non-empty and 'ManagedMediaSource' in window, which in practice means modern Safari (video-dev/hls.js, README, accessed 2026-11-16).

Whichever order you call loadSource and attachMedia in, call play() only after MANIFEST_PARSED, when the variants are known. Time to first frame is measured from MEDIA_ATTACHING, as Figure 3 shows.

A vertical timeline of seventeen steps from page load to the first painted frame. Three are calls your code makes, marked in orange: new Hls(config), which wires the controllers with no I/O yet; hls.attachMedia(video), which binds the instance to the video element; and hls.loadSource(url), which hands the playlist URL to the loader. The rest are events the library fires, in order: MEDIA_ATTACHING, where the buffer controller makes a MediaSource; MEDIA_ATTACHED, where the MediaSource is open and SourceBuffers can be added; MANIFEST_LOADING, the HTTP GET for master.m3u8; MANIFEST_LOADED, bytes back from the CDN and not yet parsed; MANIFEST_PARSED, variants known and play() now safe; LEVEL_LOADING, the media playlist fetch for one variant; LEVEL_LOADED, segment list and refresh schedule; FRAG_LOADING, the first media segment fetched; FRAG_LOADED, bytes in and the transmux to fMP4 running; FRAG_PARSING_INIT_SEGMENT, moov built with codec and timescale known; BUFFER_APPENDING, appendBuffer() in flight; BUFFER_APPENDED, updateend fired and the bytes decodable; and FRAG_BUFFERED, where the segment is buffered and the TTFF stopwatch stops. The last step, in green, is the first frame painted, when the viewer sees the stream. A blue rail down the left marks the TTFF stopwatch, from MEDIA_ATTACHING to the first FRAG_BUFFERED, 0.6 to 1.5 seconds on broadband. Figure 3. The event sequence from page load to first frame. Time-to-first-frame is the wall-clock distance between MEDIA_ATTACHING and the first FRAG_BUFFERED for the video track.

Error handling, the way you ship it

Errors in hls.js arrive through a single event: Hls.Events.ERROR. The payload is a tagged object with three fields you must read every time (type, details and fatal) and a fourth data field whose shape depends on the details. There are five error types, and they map to four recovery paths.

Hls.ErrorTypes.NETWORK_ERROR is anything the network layer surfaced: manifest 404, fragment 404, fragment timeout, HTTP status 5xx, or XMLHttpRequest aborted. When fatal, the documented recovery is hls.startLoad(): restart the segment-fetch state machine and try again. The library's own example in the API docs lists exactly that (video-dev/hls.js, docs/API.md, master branch, accessed 2026-10-17). v1.7 adds a non-fatal PLAYLIST_UNCHANGED_ERROR for live playlists that stop updating, controlled by liveMaxUnchangedPlaylistRefresh.

Hls.ErrorTypes.MEDIA_ERROR is anything the MSE layer or the browser's decoder surfaced: an appendBuffer that the SourceBuffer rejected, a QuotaExceededError, a buffer-hole stall the gap controller could not skip, a decoder error from the browser. When fatal, the documented recovery is hls.recoverMediaError() once; if a second media error fires within a few seconds of the first, call hls.swapAudioCodec() then hls.recoverMediaError() (video-dev/hls.js, docs/API.md, master branch). The audio-codec swap is the recovery for the specific failure mode where the browser's decoder cannot handle a mid-stream codec change.

Hls.ErrorTypes.KEY_SYSTEM_ERROR covers everything the EME path threw: license-request rejected, key status of internal-error or output-restricted, CDM crashed. There is no automatic recovery, because the cause is almost always either a misconfigured license server or a device-policy decision (a Widevine L3 phone trying to play 4K, an HDCP-not-detected condition). Show the user a "this content is not available on this device" message and emit a telemetry event.

Hls.ErrorTypes.MUX_ERROR and Hls.ErrorTypes.OTHER_ERROR are the rare cases: the remuxer could not allocate or build an output segment (remuxAllocError), or an internal handler threw. A malformed segment shows up instead as a media error with fragParsingError. There is no recovery; log it, switch to a different variant if you can, and surface a generic error to the user.

Every production player ships some flavour of this pattern:

let mediaErrorRecoveryAttempted = false;

hls.on(Hls.Events.ERROR, (event, data) => {
  if (!data.fatal) return;             // non-fatal: log and keep playing
  switch (data.type) {
    case Hls.ErrorTypes.NETWORK_ERROR:
      telemetry.error('hls.network', data);
      hls.startLoad();                 // restart the fetch state machine
      break;
    case Hls.ErrorTypes.MEDIA_ERROR:
      telemetry.error('hls.media', data);
      if (mediaErrorRecoveryAttempted) {
        hls.swapAudioCodec();
        hls.recoverMediaError();
      } else {
        mediaErrorRecoveryAttempted = true;
        hls.recoverMediaError();
        setTimeout(() => { mediaErrorRecoveryAttempted = false; }, 5000);
      }
      break;
    default:
      telemetry.error('hls.fatal', data);
      hls.destroy();
      showUnplayableMessage();
  }
});

What does "HLS fatal error, destroy" mean? It means the player hit a fatal error and the code tore the instance down with hls.destroy(), which detaches it from the video element and stops all loading. A common mistake is to call hls.destroy() on every fatal error. Destroying the instance unbinds it from the video element and forces the user to reload the page; doing it on a recoverable NETWORK_ERROR is a one-line bug that ships every quarter. Read data.type first; destroy only when there is no recovery path.

hls.js error reference: what each error message means

An hls.js error reaches your Hls.Events.ERROR handler as three fields, and wrapper players usually print them in this order: the error type (networkError, mediaError, keySystemError, muxError, otherError), whether it is fatal, and the details string that names the exact failure. The type tells you which recovery call to make; the details string tells you what to fix. The strings below are the values of Hls.ErrorDetails in src/errors.ts and docs/API.md on the master branch (checked 16 November 2026).

What does "hls.js error: mediaError - fatal: true - bufferAddCodecError" mean? The browser refused to create a SourceBuffer for a codec string in your playlist: MediaSource.addSourceBuffer() threw for that MIME type. hls.js first raises it as non-fatal, removes every level that uses the unsupported codec and switches to another one; when no playable level is left, the error becomes fatal (video-dev/hls.js, buffer-controller.ts and error-controller.ts, master branch). The fix is almost never in the player. Check that the CODECS attribute on each EXT-X-STREAM-INF matches what the packager actually wrote, test the string with MediaSource.isTypeSupported('video/mp4; codecs="…"') on the failing device, and keep an H.264 rung next to any HEVC or AV1 rung.

Details stringType, fatalUsual causeWhat to do
manifestLoadError, manifestLoadTimeOutnetwork, fatalWrong playlist URL, 403/404 from the CDN, CORS headers missing, signed URL expiredOpen the URL in the browser network tab; fix CORS or token, then hls.loadSource() again
manifestParsingErrornetwork, fatalThe response is not an HLS playlist (an HTML error page, an empty body, no #EXTM3U)Check what the origin really returns; validate with Apple's mediastreamvalidator
levelLoadError, levelLoadTimeOutnetwork, fatal or notA variant (media) playlist is missing or slowFatal: hls.startLoad(); recurring: fix the packager or CDN path for that rung
fragLoadError, fragLoadTimeOutnetwork, fatal or notSegment 404, 5xx or slow first byte. By default hls.js retries a timeout 4 times, and an HTTP error 6 times with a 1 to 8 s back-off, before it gives upFatal: hls.startLoad(); tune fragLoadPolicy for slow links
keyLoadErrornetwork, not fatalAES-128 key URL unreachable or not authorisedCheck key URL, cookies and CORS; add auth headers in xhrSetup
playlistUnchangedErrornetwork, not fatal (v1.7+)A live playlist stopped updating for liveMaxUnchangedPlaylistRefresh reloadsTreat as "stream ended or encoder down"; show a live-ended state
bufferAddCodecErrormedia, fatal when no level is leftBrowser cannot decode a codec named in CODECSFix the codec string; keep an H.264 fallback rung
manifestIncompatibleCodecsError, bufferIncompatibleCodecsErrormedia, fatalNo variant in the playlist uses a codec this browser supportsAdd a compatible rendition; there is nothing to recover on the client
bufferStalledErrormedia, usually not fatalThe buffer ran dry: slow network, a gap in the stream or an ABR choice that was too highNon-fatal: log it as a rebuffer; fatal after nudges: hls.recoverMediaError()
bufferAppendError, bufferFullErrormedia, fatal or notThe SourceBuffer rejected a segment, or the buffer quota was hitFatal: hls.recoverMediaError(); full: lower maxBufferLength
fragParsingErrormedia, fatal or notA malformed segment the transmuxer cannot readRe-package the asset; switch rung if the error is non-fatal
keySystemNoKeys, keySystemLicenseRequestFailedkeySystem, fatalDRM license server rejected the request (first 4xx or 3 failures), or no usable keyShow "not available on this device"; check license URL and drmSystems config

What does "hls.js fatal error: network error" mean? A playlist or segment request failed and the library used up its retries, so loading stopped. Call hls.startLoad() once the network is back. If the same URL keeps failing, the cause is on the server side, usually CORS, an expired token or a missing file on the CDN.

Low-latency HLS through hls.js

The Apple low-latency HLS extension, abbreviated LL-HLS, lets a player download partial segments ("parts") before the full segment finishes encoding, so live latency drops from the 10–30 seconds of standard HLS to a few seconds. Apple's authoring spec recommends a one-second part target and a PART-HOLD-BACK of at least three parts, which puts the player about 3 seconds behind the live edge (Apple, HLS Authoring Specification for Apple Devices, §14 Low-Latency HLS, accessed 2026-10-17). hls.js has supported LL-HLS since v1.0; v1.7.1 (19 August 2026) fixed a permanent stall when loading preload-hinted parts of encrypted low-latency streams, and v1.7.4 (28 October 2026) stopped the player skipping unloaded trailing parts at fragment boundaries and fixed an LL-HLS subtitle stall. Apple dropped the HTTP/2 server-push requirement in January 2020 and replaced it with the EXT-X-PRELOAD-HINT tag, so articles that describe LL-HLS as requiring HTTP/2 push are out of date; the current spec uses blocking playlist reload, preload hints and rendition reports as the three low-latency primitives.

You enable it with a configuration switch; no code rewrite is needed:

const hls = new Hls({
  lowLatencyMode: true,        // LL-HLS on (this is the default)
  liveSyncDuration:    3,      // try to stay ~3 seconds behind the live edge
  maxLiveSyncPlaybackRate: 1.1 // catch up to live by playing at 1.1x when behind
});

The two duration knobs deserve a sentence each. liveSyncDuration is the target distance, in seconds, from the live edge. Set it too low and the player will rebuffer on every network blip; set it too high and you have not actually shipped low latency. maxLiveSyncPlaybackRate lets the player accelerate playback slightly when it drifts behind, so the user catches back up to the live edge without a visible seek; the default is 1 (off), and most LL-HLS deployments set it to 1.05–1.1.

LL-HLS performance through hls.js is gated as much by the path between the origin and the player as by the player itself. A CDN that does not support HTTP/2 (or HTTP/3) and blocking playlist reload negates the benefit; an LL-HLS-capable player on a non-LL-HLS CDN runs as a standard HLS player. Our LL-HLS deep dive walks the CDN-side requirements.

The numbers operators actually care about

The numbers below are the ones an operator measures on a production hls.js deployment.

MetricDefinitionHealthy range (typical OTT, Fora Soft projects, 2026)
Time to first frame (TTFF)Wall-clock from MEDIA_ATTACHING to the first FRAG_BUFFERED for video0.6–1.5 s on broadband; 1.5–3 s on cellular
Rebuffer ratioTotal rebuffer time ÷ total watch time, per session< 0.5% target; 1–3% production reality
ABR switch rateNumber of LEVEL_SWITCHED events per minute of playback0.2–1.0 per minute steady state
Top-rung shareFraction of session time spent on the top rung0.6–0.9 on broadband; lower is fine on cellular
Fatal error rateSessions with at least one fatal Hls.Events.ERROR ÷ all sessions< 0.5% target; 1–2% production reality
Live edge distanceFor live, liveSyncPosition − currentTime averaged over a minuteTarget ± 0.5 s for LL-HLS; ± 3 s for standard HLS

These all come out of the hls.js event stream; no separate instrumentation library is required. Mux Data, Conviva, Bitmovin Analytics, and Datazoom all wrap hls.js's events and ship them off to a backend; our Player observability and metrics article walks the schema each vendor uses and tells you when to build versus buy. Since v1.7.0 hls.js can also send Common Media Client Data version 2 to your CDN (cmcd: { version: 2 }), including event reports, though not every v2 field is supported yet. The math for a rebuffer ratio is the same regardless of vendor: sum the stall time (from a BUFFER_STALLED_ERROR or the video element's waiting event until playback resumes), divide by the milliseconds of actual playback, multiply by 100. A 0.5% target on a 60-minute session is 18 seconds of rebuffering, which is roughly the loss budget of one bad segment per session.

When to fork it (almost never) and when to monkey-patch it (more often than you think)

The library is open source under Apache 2.0, and the temptation to fork it for "just this one feature" is real and almost always wrong. The problem is operational, not legal or moral. hls.js patch releases often land weeks apart: v1.7.0 to v1.7.4 shipped between 12 August and 28 October 2026, and v1.7.4 alone lists 35 fixes. A typical patch is a set of fixes against playback corner cases on devices you do not own (Tizen 4.0 from 2018, a webOS 5 build from a 2020 LG, a 5-year-old PlayStation). A fork stops collecting those fixes the moment it diverges. What to do instead, in order of preference:

First, use configuration. Most things people fork to change are exposed as Hls constructor options: xhrSetup, fetchSetup, loader, manifestLoadPolicy, playlistLoadPolicy, fragLoadPolicy, lowLatencyMode, liveSyncDuration, liveMaxLatencyDuration, the entire drmSystems object, every ABR factor. The full list is in src/config.ts on the master branch and it is the first place to look before opening an issue, let alone forking.

Second, replace a controller. The library exposes abrController, audioTrackController, subtitleTrackController, and the loader subsystem as user-replaceable. If you want a custom ABR (buffer-based, learned or server-driven), write a class and pass it in the config (abrController, audioTrackController, subtitleTrackController, loader). The base class signature is stable across the v1.6 and v1.7 series: v1.7 removed no public exports and needs no runtime changes, only stricter TypeScript types (video-dev/hls.js, MIGRATING.md).

Third, monkey-patch from outside. If you need to mutate the playlist after fetch (rewrite segment URLs to add a token, strip a misencoded EXT-X-DATERANGE, redirect to a backup origin), use xhrSetup or fetchSetup to change the request (headers, tokens, URL), and a custom playlist or fragment loader (pLoader, fLoader) to rewrite the response. No fork is needed.

Forking is the right answer only when the bug you need to fix is in transmuxer logic, parser logic, or stream-controller state-machine logic and the change is too small to send upstream. In nine years of shipping hls.js to production, we have done this twice. Both times the patch was a single line; both times we sent it upstream and dropped the fork within two months.

Common pitfalls and what to do about them

The same five mistakes show up in every code review of a production hls.js integration. Knowing them up front saves a quarter of debugging.

The first is not deciding how Apple devices play. hls.js cannot run on iPhones before iOS 17.1, which have no MSE or Managed Media Source, so the canPlayType('application/vnd.apple.mpegurl') fallback is mandatory. Do not treat a non-empty canPlayType answer as "this is Safari": desktop Chrome 142 and later answers "maybe" too. On newer iPhones and on desktop Safari both paths work; pick one on purpose, because the native path gives you hardware decoding, AirPlay and system Picture in Picture, while hls.js gives you the same ABR, telemetry and error handling as on every other browser.

The second is calling hls.destroy() on every error. We covered the recovery pattern earlier; the rule is startLoad() for NETWORK_ERROR, recoverMediaError() for MEDIA_ERROR, destroy() only when there is no recovery.

The third is listening for MANIFEST_LOADED instead of MANIFEST_PARSED. MANIFEST_LOADED fires after the HTTP fetch finishes; MANIFEST_PARSED fires after the library has parsed the variants and is ready for play(). Calling play() on MANIFEST_LOADED can start playback before any rung is chosen.

The fourth is assuming live currentTime starts at zero. For VOD it does; for live it starts at the live edge, which can be a number like 1719428400 (Unix epoch seconds) or a smaller number depending on the manifest. UI code that draws a progress bar must use seekable.start(0) and seekable.end(0) as the rails, not 0 and duration.

The fifth is not setting per-network-condition timeouts. In current hls.js the old manifestLoadingTimeOut and fragLoadingTimeOut (10 and 20 seconds) are deprecated in favour of load policies: by default fragLoadPolicy allows 10 seconds to the first byte and 120 seconds for the whole segment, and manifestLoadPolicy allows 20 seconds for the playlist (video-dev/hls.js, src/config.ts, v1.7.4). Those are sensible on broadband and pessimistic on satellite or 3G. Tighten them on broadband and loosen them on detected slow links; the library does not auto-tune this, so your code has to.

Frequently asked questions

What is hls.js?

hls.js is an open-source JavaScript library that plays HLS video in browsers through Media Source Extensions. It handles playlist parsing, adaptive bitrate, buffering, DRM and error recovery; you supply the UI.

Where is the official hls.js website?

The project lives at github.com/video-dev/hls.js, with the README, the API documentation in docs/API.md and the releases; the package is published on npm as hls.js.

What is the latest version of hls.js?

v1.7.4, released 28 October 2026. v1.7.0 (12 August 2026) added I-frame playlist support, CMCD v2 and better protected-content handling with no breaking runtime changes from v1.6; v1.7.4 is a fix release for LL-HLS, DRM, subtitles and buffering.

How do I load hls.js from a CDN, and what is hls.min.js?

Add <script src="https://cdn.jsdelivr.net/npm/hls.js@1.7.4/dist/hls.min.js"></script> and use the global Hls. hls.min.js is the minified UMD build of the library, about 624 KB raw and 190 KB gzipped for v1.7.4.

Does Chrome play HLS natively now?

Yes, desktop Chrome and Edge 142 and later have a built-in HLS player, but it gives you no ABR control or hls.js events, and the hls.js README still recommends Hls.isSupported() first.

Is hls.js a video player?

It is a playback engine, not a skinned player: it ships no buttons or controls. Players such as Video.js, JW Player and Plyr, or your own UI, sit on top of it.

Does hls.js work on iPhone?

Yes, on iOS 17.1 and later through Managed Media Source, since hls.js v1.5.0. On older iPhones it cannot run, so you set video.src to the playlist and let Safari play HLS natively.

Is hls.js free for commercial use?

Yes. hls.js is released under the Apache 2.0 license, which allows commercial use as long as you keep the license and notices.

Can hls.js play MPEG-DASH?

No. hls.js plays HLS and LL-HLS only; for DASH use dash.js or Shaka Player.

What does bufferAddCodecError mean in hls.js?

The browser could not create a SourceBuffer for a codec listed in your playlist. hls.js drops the levels with that codec and becomes fatal only when none is left; fix the CODECS string or add an H.264 rung.

How do I recover from an hls.js fatal error?

Read data.type: call hls.startLoad() for a fatal network error, hls.recoverMediaError() for a fatal media error, and hls.destroy() only when neither recovers playback.

↓ Free download: hls.js Production Checklist (2026)One printable page: the version to pin, every controller and the events it emits, the ABR and LL-HLS knobs worth changing, the multi-DRM matrix, the four error families with their recovery calls, and the five mistakes that show up in every code review.

Where Fora Soft fits in

We have shipped hls.js inside production players for video conferencing, OTT, e-learning, telemedicine, and video surveillance since the library was at v0.7, long enough that the "Safari branch" and the "ManagedMediaSource branch" are both reflexes by now. Trust is rarely earned on the happy path. It comes from the recovery story, the smart-TV port that gets the buffer controller through a Tizen 4.0 quirk, the LL-HLS deployment whose CDN needed three rounds of tuning before the player's liveSyncDuration actually held, and the multi-DRM stack that ships Widevine + FairPlay + PlayReady from one packager. If your team is building a video product on the open web in 2026, hls.js is in your bundle whether you wrote the integration yourself or inherited it, and the difference between the two is usually a quarter of post-launch QoE work nobody planned for. Our video streaming development team owns that player and LL-HLS tuning work, and our OTT and IPTV platform builds ship it with multi-DRM on web, mobile and Smart TV. If you already have a player in production, a code audit of your player integration is the fastest way to find the missing error paths and ABR defaults before your users do.

Video Streaming: A Complete Guide to Video Delivery: From ABR and CDNs to Players, WebRTC, DRM, and the Economics of Streaming - book cover

The book

Video Streaming: A Complete Guide to Video Delivery: From ABR and CDNs to Players, WebRTC, DRM, and the Economics of Streaming

This article takes one player apart controller by controller. Book 3 of the handbook is the rest of that player's world: 1,182 pages on ABR and the algorithms that pick a rung, the CDN and cache layer that decides whether your segments arrive in time, the recovery patterns behind startLoad() and recoverMediaError(), multi-DRM, QoE monitoring, and what delivery costs per viewer-hour. Read it and the config object above stops being a list of knobs: liveSyncDuration, abrBandWidthUpFactor and fragLoadPolicy become numbers you can defend in a design review. Written by Nikolay Sapunov, CEO at Fora Soft.

Read it on Amazon →Kindle & paperback · Fora Soft Video Engineering Handbook

Is your hls.js integration ready for the devices you actually ship to?

Send us your player code and the device list you have to cover, and we will tell you which error paths you are missing, which ABR defaults are working against you, and what the Safari and smart-TV branches still need — 250+ video products shipped since 2005.

Book a 30-min call →WhatsApp →Email us →

See our case studies

References

  1. video-dev/hls.js, README and source tree, master branch, <https://github.com/video-dev/hls.js> (accessed 2026-11-16). Source of the README definition, the native-HLS fallback rule and the dist/ build list.
  2. video-dev/hls.js, API.md, master branch, <https://github.com/video-dev/hls.js/blob/master/docs/API.md> (accessed 2026-11-16). Source of the error details list.
  3. video-dev/hls.js, Release v1.7.4, 28 October 2026, <https://github.com/video-dev/hls.js/releases/tag/v1.7.4> (accessed 2026-11-16). Source of the LL-HLS, DRM, MediaSource and gap fixes and the reuseKeySessions option.
  4. Mux, Investigating elevated playback errors on Chrome version 141.0.7390.123 and later, status page, 23 October to 5 November 2025, <https://status.mux.com/incidents/g4wcv5cm02sg> (accessed 2026-11-16). Source of the Chrome 141/142 native HLS rollout and the prefer-MSE advice.
  5. Tech-ish, news report on native HLS playback in Chrome and Edge on desktop, 8 December 2025, <https://tech-ish.com/2025/12/08/google-chrome-microsoft-edge-chromium-native-hls-playback-desktop> (accessed 2026-11-16). Source of Chrome and Edge 142 native HLS on desktop.
  6. video-dev/hls.js, Release v1.6.15, 19 November 2025, <https://github.com/video-dev/hls.js/releases/tag/v1.6.15> (accessed 2026-10-17). Source of the FairPlay key-ID patching fix.
  7. video-dev/hls.js, Release v1.7.0, 12 August 2026, and Release v1.7.1, 19 August 2026, <https://github.com/video-dev/hls.js/releases> (accessed 2026-10-17). Source of I-frame playback, CMCD v2, abrSwitchInterval, errorPenaltyExpireMs, appendTimeout, MEDIA_SOURCE_REQUIRES_RESET, BUFFER_APPEND_NO_PROGRESS, PLAYLIST_UNCHANGED_ERROR, and the ManagedMediaSource fixes.
  8. video-dev/hls.js, src/controller/abr-controller.ts and src/controller/stream-controller.ts, master branch, <https://github.com/video-dev/hls.js/tree/master/src/controller> (accessed 2026-10-17). Primary source for ABR algorithm and stream-controller state machine.
  9. IETF RFC 8216, HTTP Live Streaming, R. Pantos and W. May (eds.), August 2017, <https://www.rfc-editor.org/rfc/rfc8216> (accessed 2026-10-17). The base HLS protocol specification; controlling document for playlist syntax and segment semantics that hls.js implements.
  10. Apple Inc., HLS Authoring Specification for Apple Devices, last revised 26 June 2025, §14 Low-Latency HLS, <https://developer.apple.com/documentation/http-live-streaming/hls-authoring-specification-for-apple-devices> (accessed 2026-10-17). Controlling document for LL-HLS; Apple removed the HTTP/2 server-push requirement in January 2020, replacing it with EXT-X-PRELOAD-HINT; older articles still describe push as required. The article followed Apple's revised text over the older third-party paraphrases.
  11. W3C, Media Source Extensions™, Recommendation 17 November 2016, with Media Source Extensions 2 as a Working Draft, latest 9 November 2026, which defines ManagedMediaSource, <https://www.w3.org/TR/media-source/> (accessed 2026-11-16). The browser API hls.js feeds bytes into.
  12. W3C, Encrypted Media Extensions, Recommendation 18 September 2017, <https://www.w3.org/TR/encrypted-media/> (accessed 2026-10-17). The browser API the EME controller talks to; spec defines the requestMediaKeySystemAccess surface and the MediaKeySession lifecycle the hls.js EMEController orchestrates.
  13. npm, hls.js registry download API, accessed 2026-11-16, <https://api.npmjs.org/downloads/point/last-week/hls.js>. Source of the 14,796,794 downloads for 9–15 November 2026; the package metadata (registry.npmjs.org/hls.js) gives the Apache-2.0 license and the latest version 1.7.4.
  14. Spiteri K., Urgaonkar R., Sitaraman R. K., BOLA: Near-Optimal Bitrate Adaptation for Online Videos, IEEE INFOCOM 2016, <https://arxiv.org/abs/1601.06748> (accessed 2026-10-17). The buffer-based ABR algorithm cited alongside throughput-based ABR; hls.js does not ship a BOLA controller; dash.js does.
  15. Mux Inc. engineering blog, An update on Low Latency HLS live streaming, Part 2, <https://www.mux.com/blog/low-latency-hls-part-2> (accessed 2026-10-17). Production-deployer perspective on LL-HLS used to cross-check the article's latency-range claims; spec text was preferred where Mux's deployment specifics differed.
  16. WebKit, WebKit Features in Safari 17.1, <https://webkit.org/blog/14735/> (accessed 2026-10-17). Managed Media Source on iPhone and its AirPlay / remote-playback condition.
  17. IETF, draft-pantos-hls-rfc8216bis-22, HTTP Live Streaming 2nd Edition, 1 May 2026, <https://datatracker.ietf.org/doc/draft-pantos-hls-rfc8216bis/> (accessed 2026-10-17).