Repository navigation
PERF: Load video streams only once playback starts - #111
Merged
ZogStriP merged 1 commit intoOct 23, 2026
Merged
Conversation
Previously, hls.js started loading levels and fragments as soon as the manifest was parsed, so every video using hls.js buffered up to 30 seconds of video as soon as it rendered, even if nobody played it and the Mux poster already served as the preview. This change sets `autoStartLoad: false` so only the master playlist is fetched up front, and calls `startLoad()` on the first `play` event. An early play is safe because hls.js defers a `startLoad()` that arrives before the manifest is parsed. The listener uses the render's abort signal, so a replaced player never starts loading a destroyed instance. It also enables `capLevelToPlayerSize` on that first play, so hls.js doesn't pick a rendition larger than the player. Capping polls the player size every second, so enabling it up front would run that timer for every video on the page, played or not. The native HLS path, used where hls.js isn't supported, is unchanged. The trade-off is a short delay on the first play, and no duration in the player controls until then.
This was referenced Oct 22, 2026
Grubba27
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, hls.js started loading levels and fragments as soon as the manifest was parsed, so every video using hls.js buffered up to 30 seconds of video as soon as it rendered, even if nobody played it and the Mux poster already served as the preview.
This change sets
autoStartLoad: falseso only the master playlist is fetched up front, and callsstartLoad()on the firstplayevent. An early play is safe because hls.js defers astartLoad()that arrives before the manifest is parsed. The listener uses the render's abort signal, so a replaced player never starts loading a destroyed instance.It also enables
capLevelToPlayerSizeon that first play, so hls.js doesn't pick a rendition larger than the player. Capping polls the player size every second, so enabling it up front would run that timer for every video on the page, played or not.The native HLS path, used where hls.js isn't supported, is unchanged.
The trade-off is a short delay on the first play, and no duration in the player controls until then.
Part of a stack of PRs, to be merged in order: