Size

Import only what you need

The player's size depends on its configuration. You give it the engine stages your streams need, and you import the packages your viewers need. The player alone is 68.3 KB. With HLS on demand it is 76.2 KB. With the full preset and every package it is 200.4 KB.

Configurations

Each row is the player in one configuration, minified and gzipped. The first row is the player with no stage: the element, its controls and the engine's core. Every other row includes it. A row that starts with + adds to the row above it.

  1. Player alonemain · no stages68.3 KB
  2. + HLS on demandmain · + hls-cmaf, abr76.2 KB
  3. + livemain · + hls-live78.3 KB
  4. + subtitlesmain · + text-webvtt, text-webvtt-segmented83.0 KB
  5. + live captionsmain · + live-captions87.7 KB
  6. + Chromecastmain · + cast92.2 KB
  7. + Widevine, FairPlaymain · + eme-core, eme-cenc, eme-fairplay92.9 KB
  8. Player + DASH on demandmain · dash-cmaf, abr80.3 KB
  9. + 360° videomain · + 36087.7 KB
  10. Player + hls presetmain · the preset attribute92.9 KB
  11. Player + full presetmain · the preset attribute134.3 KB
  12. + every packagemain · + every package200.4 KB
min+gzip · KB · the player with the engine stages and the packages of each row

HLS with live, subtitles, Chromecast and DRM

The player first, then HLS with fMP4 segments on demand, then one addition per row. Stop at the row that covers your streams.

StepImportsAddsTotal
Player@mattebox/player68.3 KB
+ HLS on demandmattebox/protocols/hls-cmaf, mattebox/stages/abr+7.9 KB76.2 KB
+ livemattebox/protocols/hls-live+2.1 KB78.3 KB
+ subtitlesmattebox/stages/text-webvtt, mattebox/stages/text-webvtt-segmented+4.7 KB83.0 KB
+ live captions@mattebox/player-live-captions+4.7 KB87.7 KB
+ Chromecast@mattebox/player-cast+4.5 KB92.2 KB
+ Widevine, FairPlaymattebox/stages/eme-core, mattebox/stages/eme-cenc, mattebox/stages/eme-fairplay+0.7 KB92.9 KB

Widevine and FairPlay add 0.7 KB because the player already includes the engine's EME code, for Safari's own HLS.

The code of the last row:

import { MatteboxPlayerElement } from '@mattebox/player';
import '@mattebox/player-live-captions';
import '@mattebox/player-cast';
import hlsCmaf from 'mattebox/protocols/hls-cmaf';
import abr from 'mattebox/stages/abr';
import hlsLive from 'mattebox/protocols/hls-live';
import textWebvtt from 'mattebox/stages/text-webvtt';
import textWebvttSegmented from 'mattebox/stages/text-webvtt-segmented';
import emeCore from 'mattebox/stages/eme-core';
import emeCenc from 'mattebox/stages/eme-cenc';
import emeFairplay from 'mattebox/stages/eme-fairplay';

MatteboxPlayerElement.define({
  stages: [
    hlsCmaf(),
    abr(),
    hlsLive(),
    textWebvtt(),
    textWebvttSegmented(),
    emeCore(),
    emeCenc(),
    emeFairplay(),
  ],
});

DASH with 360° video

The player first, then DASH on demand, then the 360° view.

StepImportsAddsTotal
Player@mattebox/player68.3 KB
+ DASH on demandmattebox/protocols/dash-cmaf, mattebox/stages/abr+12.0 KB80.3 KB
+ 360° video@mattebox/player-360+7.4 KB87.7 KB

The code of the last row:

import { MatteboxPlayerElement } from '@mattebox/player';
import '@mattebox/player-360';
import dashCmaf from 'mattebox/protocols/dash-cmaf';
import abr from 'mattebox/stages/abr';

MatteboxPlayerElement.define({
  stages: [
    dashCmaf(),
    abr(),
  ],
});

Presets

Without a stage list, the player loads a preset: the one in its preset attribute, or full by default. A preset includes every stage its protocol may need, and a bundler cannot remove the ones your streams do not use.

  • The player with the hls preset is 92.9 KB.
  • The player with the full preset is 134.3 KB.
  • The player with the full preset and every package is 200.4 KB.
<mattebox-player preset="hls" src="https://example.com/master.m3u8"></mattebox-player>

A stage list takes one call to define(). The player's guide shows it.

Packages

The size each package adds to the player with the full preset. The Chromecast row leaves out Google's sender SDK, which the button loads from Google when the page shows it.

  1. TV remotemain · @mattebox/player-spatial-nav1.6 KB
  2. preferencesmain · @mattebox/player-preferences2.7 KB
  3. live captionsmain · @mattebox/player-live-captions4.3 KB
  4. game controllersmain · @mattebox/player-spatial-nav/gamepad4.5 KB
  5. Chromecastmain · @mattebox/player-cast4.8 KB
  6. subtitle translationmain · @mattebox/player-subtitle-translation5.3 KB
  7. 360° videomain · @mattebox/player-3607.0 KB
  8. playlistmain · @mattebox/player-playlist7.1 KB
  9. transcriptmain · @mattebox/player-transcript10.1 KB
  10. adsmain · @mattebox/player-ads10.7 KB
  11. diagnosticsmain · @mattebox/player-diagnostics13.5 KB
min+gzip · KB · the player with the full preset and the package, less the player alone

Method

The player repository's size script bundles each configuration from the built packages with rolldown, minifies it, and compresses it with gzip at level 9. A preset's code counts only when the configuration loads that preset. The same script draws the package chart in the player's README.