Skip to content

feat(poster): add support for marking player as maincontent#9173

Open
kontrollanten wants to merge 2 commits intovideojs:mainfrom
kontrollanten:feat/9171-poster-maincontent
Open

feat(poster): add support for marking player as maincontent#9173
kontrollanten wants to merge 2 commits intovideojs:mainfrom
kontrollanten:feat/9171-poster-maincontent

Conversation

@kontrollanten
Copy link
Copy Markdown
Contributor

@kontrollanten kontrollanten commented Apr 20, 2026

Description

When maincontent is set to true the poster img element will get loading=eager and fetchpriority=high to decrease LCP time.

Usage

maincontent: true

    var player = videojs(vid, { maincontent: true });
image

Default mode

    var player = videojs(vid);
image

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
    • Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab)
    • Has no changes to JSDoc which cause npm run docs:api to error
  • Reviewed by Two Core Contributors

I'm not sure if any example should be created, and if so where to put it. The same goes with the documentation.

closes #9171

@welcome
Copy link
Copy Markdown

welcome Bot commented Apr 20, 2026

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@kontrollanten kontrollanten changed the title add support for marking player as maincontent feat(poster): add support for marking player as maincontent Apr 20, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.94%. Comparing base (69ea0e0) to head (edd7b45).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9173      +/-   ##
==========================================
+ Coverage   84.32%   84.94%   +0.62%     
==========================================
  Files         120      120              
  Lines        8153     8157       +4     
  Branches     1964     1967       +3     
==========================================
+ Hits         6875     6929      +54     
+ Misses       1278     1228      -50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

When maincontent is set to true the poster img element will get
loading=eager and fetchpriority=high to decrease LCP time.

closes videojs#9171
@mister-ben
Copy link
Copy Markdown
Contributor

At the time loading="lazy" was added, Lighthouse would complain if it were absent, even on a prominent player. Iirc it was said that browsers would disregard the lazy directive on elements it deemed to have priority. Since the recommendation has changed, this change is more than reasonable.

Nit: The option name should be camel case like other options.

@kontrollanten
Copy link
Copy Markdown
Contributor Author

Thanks for reviewing! I've now changed maincontent to mainContent.

@mister-ben mister-ben added minor This PR can be added to a minor release. It should not be added to a patch release. needs: LGTM Needs one or more additional approvals labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor This PR can be added to a minor release. It should not be added to a patch release. needs: LGTM Needs one or more additional approvals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to make player as main content (eager/prioritized loading)

2 participants