next-cloudinary icon indicating copy to clipboard operation
next-cloudinary copied to clipboard

[Feature] Add Lazy Loading Support for CldVideoPlayer

Open Vaibhav91one opened this issue 1 month ago • 3 comments

CldVideoPlayer loads scripts immediately on mount, impacting performance for videos below the fold. , video player has no lazy loading support.

Solution

Add loading="lazy" prop using Intersection Observer to defer script loading until video enters viewport.

Usage

<CldVideoPlayer
  src="my-video"
  width={1920}
  height={1080}
  loading="lazy"  // New prop (default: "eager")
/>

Acceptance Criteria

  • [ ] Add loading prop: "eager" (default) | "lazy"
  • [ ] Use Intersection Observer for viewport detection
  • [ ] Show placeholder/poster while lazy loading
  • [ ] No breaking changes (backward compatible)
  • [ ] Add tests for lazy loading behavior
  • [ ] Update TypeScript types and documentation

Benefits

~50-200KB savings per lazy-loaded player + improved LCP/TBT

Checklist

  • [x] I am willing to raise a PR for this feature
  • [x] I have read the Contributing Guidelines

Vaibhav91one avatar Oct 13 '25 04:10 Vaibhav91one

Hi @colbyfayock, Please let me know if this feature is valid to work on or not.

Vaibhav91one avatar Oct 13 '25 08:10 Vaibhav91one

@eportis-cloudinary Please let me @Vaibhav91one if this feature is valid to work on or not

devpatocld avatar Oct 22 '25 04:10 devpatocld

Hi @eportis-cloudinary and @devpatocld. Any update on this? If feasible, I would like to do this under hacktoberfest period. If not feasbile right now, I can raise the PR later also.

Vaibhav91one avatar Oct 28 '25 08:10 Vaibhav91one