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.
- Player alonemain · no stages68.3 KB
- + HLS on demandmain · + hls-cmaf, abr76.2 KB
- + livemain · + hls-live78.3 KB
- + subtitlesmain · + text-webvtt, text-webvtt-segmented83.0 KB
- + live captionsmain · + live-captions87.7 KB
- + Chromecastmain · + cast92.2 KB
- + Widevine, FairPlaymain · + eme-core, eme-cenc, eme-fairplay92.9 KB
- Player + DASH on demandmain · dash-cmaf, abr80.3 KB
- + 360° videomain · + 36087.7 KB
- Player + hls presetmain · the preset attribute92.9 KB
- Player + full presetmain · the preset attribute134.3 KB
- + every packagemain · + every package200.4 KB
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.
| Step | Imports | Adds | Total |
|---|---|---|---|
| Player | @mattebox/player | 68.3 KB | |
| + HLS on demand | mattebox/protocols/hls-cmaf, mattebox/stages/abr | +7.9 KB | 76.2 KB |
| + live | mattebox/protocols/hls-live | +2.1 KB | 78.3 KB |
| + subtitles | mattebox/stages/text-webvtt, mattebox/stages/text-webvtt-segmented | +4.7 KB | 83.0 KB |
| + live captions | @mattebox/player-live-captions | +4.7 KB | 87.7 KB |
| + Chromecast | @mattebox/player-cast | +4.5 KB | 92.2 KB |
| + Widevine, FairPlay | mattebox/stages/eme-core, mattebox/stages/eme-cenc, mattebox/stages/eme-fairplay | +0.7 KB | 92.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.
| Step | Imports | Adds | Total |
|---|---|---|---|
| Player | @mattebox/player | 68.3 KB | |
| + DASH on demand | mattebox/protocols/dash-cmaf, mattebox/stages/abr | +12.0 KB | 80.3 KB |
| + 360° video | @mattebox/player-360 | +7.4 KB | 87.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
hlspreset is 92.9 KB. - The player with the
fullpreset is 134.3 KB. - The player with the
fullpreset 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.
- TV remotemain · @mattebox/player-spatial-nav1.6 KB
- preferencesmain · @mattebox/player-preferences2.7 KB
- live captionsmain · @mattebox/player-live-captions4.3 KB
- game controllersmain · @mattebox/player-spatial-nav/gamepad4.5 KB
- Chromecastmain · @mattebox/player-cast4.8 KB
- subtitle translationmain · @mattebox/player-subtitle-translation5.3 KB
- 360° videomain · @mattebox/player-3607.0 KB
- playlistmain · @mattebox/player-playlist7.1 KB
- transcriptmain · @mattebox/player-transcript10.1 KB
- adsmain · @mattebox/player-ads10.7 KB
- diagnosticsmain · @mattebox/player-diagnostics13.5 KB
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.