Skip to content

[Feature] Add Lazy Loading Support for CldVideoPlayer #620

@Vaibhav91one

Description

@Vaibhav91one

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions