• Since 2018 35 releases, 5 major versions
  • ~200M monthly requests on jsDelivr alone
  • 1,700+ GitHub stars, 345 forks
  • 99% of live traffic over P2P with 100 viewers, ideally

The challenge

With a CDN, every new viewer adds to the bill. Peer-to-peer delivery turns that around: viewers watching the same stream share video segments with each other, so a bigger audience costs less per viewer, not more.

Our aim goes further: bring the cost of delivery close to zero, and bring closer an era where anyone can stream 8K video to a large audience.

Doing that in a browser is hard:

  • no plugins — only WebRTC, HTML5 video and what each browser allows
  • many video players, each seeing the same stream differently
  • live streams that leave only seconds to share each new segment
  • and one rule above all: P2P must never make playback worse than the CDN alone

On top of that, the ground keeps moving: players, browsers, streaming formats and mobile platforms change every year.

An architecture that keeps evolving

P2P Media Loader has never been finished. We keep reworking its architecture to raise the P2P ratio and to adapt to how the video ecosystem changes:

VersionWhat changed
0.x (2018–2019)First versions prove P2P video in the browser for Hls.js and Shaka Player, with WebRTC and WebTorrent signaling
1.0 (2024)Full rewrite of the code and algorithms: iOS support, ES modules, P2P for split audio and video, zero configuration
2.0 (2024)Pluggable segment storage — for example, IndexedDB keeps VOD segments across page reloads — and memory limits adapted to each browser
3.0 (2026)Our own browser-native WebTorrent client with no Node.js polyfills, active peer churning, and builds for Smart TVs and older browsers
4.0 (2026)Stream identity owned by the core, and predictable swarm IDs so private trackers can allowlist swarms
5.0 (2026)A manifest-driven core, dash.js and Video.js integrations, rendezvous hashing for segment ownership, and DRM support

Key engineering decisions

One core, thin engine integrations

Video engines such as HLS.js, Shaka Player, dash.js and Video.js 8 (VHS) play segmented video through Media Source Extensions, or Managed Media Source on iOS. P2P Media Loader plugs into these engines and delivers the segments over P2P, so every player built on them gets P2P too.

Everything the engines have in common lives in one core: P2P networking over WebRTC, the WebTorrent client, manifest parsing, segment storage and the algorithms that decide what to load from peers or the CDN. Each engine integration is a small package that uses the core through its public API. That is why integrations with HLS.js, Shaka Player, dash.js and Video.js 8 came together smoothly, why adding a new engine is straightforward, and why the same core can power our native mobile library.

Hybrid by design

Playback always starts over HTTP from the CDN, and the CDN stays the fallback for anything peers can't deliver in time. P2P fills the buffer ahead of the player, so a slow peer doesn't stall playback.

One swarm, whatever the player

Since version 5.0 the core parses HLS and MPEG-DASH manifests itself and derives each segment's identity from the manifest. Viewers on HLS.js, Shaka Player, dash.js or Video.js recognize the same segments and share them in one swarm.

Rendezvous hashing applied to P2P

When a new live segment appears, one peer should fetch it from the CDN and the rest should get it over P2P. We apply rendezvous hashing among each peer's connected neighbors, not the whole swarm: every peer scores itself and its neighbors, and the lowest score fetches. It needs no coordination round trip, ownership rotates from segment to segment, and a late owner is covered by the others before playback is at risk.

Key components of the P2P networkThree browsers run P2P Media Loaders. They exchange media with each other over P2P, download from an HTTP server or CDN with an HLS or MPEG-DASH source, and find each other through WebTorrent and STUN servers, which can be public or private.BrowserP2P Media LoaderBrowserP2P Media LoaderBrowserP2P Media LoaderWebTorrent tracker+ STUN serverpublic or privateHTTP server or CDNHLS or MPEG-DASH sourceSegmentsMedia over P2PMedia over HTTPWebRTC signaling
Each browser fetches a different segment from the CDN and shares it with the others, so every segment crosses the CDN once.

Measured, not assumed

Changes are verified in real browsers against live and on-demand streams, and we measure origin traffic instead of assuming it. Placing the player deeper in the live window, for example, gives peers time to trade segments before the player asks for them, and measurably cuts what the origin has to deliver.

AI-run release testing

Before each release, an AI assistant runs a written test plan in real browsers. Several tabs join one swarm as peers, on every supported engine, on live and on-demand streams, in Chrome and Safari. The assistant seeks, changes playback rates, switches players and streams, injects network faults and runs hour-long sessions. A diagnostics ledger built into the library shows every open connection, request and timer, so a leak or a stuck request shows up without reading logs.

The assistant records each finding with its evidence and traces it to a cause; our engineers decide what to fix. It catches what unit tests miss — stalls, slow recovery after network faults — and issues in players and streams outside our code, which we report to their maintainers.

The same plan runs again for maintenance releases, so a change in a browser, a player or a stream is caught before viewers meet it.

Safe with DRM

Peers exchange segments exactly as the CDN delivers them, still encrypted. Decryption stays in the player and license requests go straight to the license server, so Widevine, PlayReady, FairPlay and HLS AES-128 streams can use P2P without weakening protection.

Runs everywhere

ES modules for modern apps and IIFE builds for Smart TVs and older browsers; memory limits that adapt to each browser; and engine integrations maintained side by side as each engine evolves.

The results

  • Nearly 200 million requests a month on the jsDelivr CDN alone, not counting copies bundled from npm or self-hosted, which no public statistics track
  • 1,700+ GitHub stars and 345 forks, and 35 releases since 2018
  • The bigger the audience, the higher the P2P share — in ideal conditions, 90% of live traffic goes over P2P with 10 viewers, 99% with 100 and 99.9% with 1,000
  • Integrations with HLS.js, Shaka Player, dash.js and Video.js 8 (VHS) — all built on one shared core, so every player on these engines gets P2P
  • A complete open-source stack, together with our wt-tracker for self-hosted signaling

What's next: native mobile apps

Today P2P Media Loader runs in mobile browsers and can be embedded into native apps. Our current R&D goes further: a Kotlin Native library that builds for both iOS and Android.

It runs a local HTTP proxy built on Kotlin Native networking APIs. Any player in the app sends its media requests to the proxy, which forwards them to a hidden WebView running the same P2P Media Loader core as on the web. The WebView provides the WebRTC engine and the runtime for our JavaScript algorithms, so apps don't have to ship their own WebRTC implementation. The library is at the prototype stage.

What it shows

P2P Media Loader is the kind of work we do best: turning a hard networking problem into a product people rely on, then improving it release after release as the platforms around it change. We bring the same approach to client projects — new algorithms, performance work on systems in production, and R&D on problems without an off-the-shelf answer.

Discuss your next product with us

Share a brief outline of what you intend to build. We will respond with a proposed team composition, delivery plan, and first milestone.

Email us a brief