Conversation
* Load player on-click * Load player on-scroll
✅ Deploy Preview for cld-video-player ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for cld-vp-esm-pages ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ry/cloudinary-video-player into VIDEO-18457-lazy-player
Comment on lines
+18
to
+26
| if (opts?.schedule?.weekly) { | ||
| const { shouldUseScheduleBootstrap, scheduleBootstrap } = await import('./schedule'); | ||
| if (shouldUseScheduleBootstrap(opts)) { | ||
| return scheduleBootstrap(id, opts, ready); | ||
| } | ||
| } | ||
|
|
||
| if (shouldUseLazyBootstrap(opts)) { | ||
| return lazyBootstrap(id, opts, ready); |
Contributor
There was a problem hiding this comment.
so i cant combine "schedule" with "lazy"?
Collaborator
Author
There was a problem hiding this comment.
That's a great question, I double-checked and yes, you can!
First of all, a scheduled player should always start with the lazy-bundle, otherwise you're loading the full-player just to display an image.
But even a player with schedule, when inside a video-schedule slot - it can still be "lazy" and load the full player only when clicked or scrolled-to 💪
Here's a quick example: https://codepen.io/tsi/pen/OPRwgVe
kalifyaniv-cloudinary
approved these changes
Apr 6, 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.
Summary
Add a
lazyoption that defers Video.js initialization until the user clicks the player or scrolls it into view. The video element displays a native<video poster>with a styled big-play-button overlay, keeping the page lightweight until activation.Changes
lazy-player.jsutility consolidating element resolution, placeholder preparation, overlay bootstrap, and deferred player loading into a single module.bootstrap-poster-url.jsutility to resolve the poster URL from player options orcloudName/publicId.player-api.jsgainsplayer()andplayers()async entry points that handle lazy bootstrap whenlazyis set, falling back to normalvideoPlayer()otherwise.configSchema.jsonextended with alazyoption (trueor{ loadOnScroll: true }).schedule.jsrefactored to reuselazy-player.jsutilities instead of duplicating element/poster logic..cld-lazy-preactivate-overlaywrapper (sizing overrides to coexist with Video.js defaults).player/playerssignatures.schedule-bootstraptests replaced.docs/lazy-player.html(UMD) anddocs/es-modules/lazy-player.html(ESM) example pages demonstrating click-to-load and scroll-to-load.How to Test
npm run test:unit- all 103 tests pass.docs/lazy-player.html- verify the player shows a poster with a play button; clicking initializes the full player with controls and autoplay.loadPlayer()API.docs/es-modules/lazy-player.htmlfor the ESM equivalent.