Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beacon is picking mp4 as an LCP element in video #6724

Open
DahmaniAdame opened this issue Jun 14, 2024 · 0 comments
Open

Beacon is picking mp4 as an LCP element in video #6724

DahmaniAdame opened this issue Jun 14, 2024 · 0 comments
Labels
module: OCI Optimize Critical Images priority: low Issues that can wait type: enhancement Improvements that slightly enhance existing functionality and are fast to implement

Comments

@DahmaniAdame
Copy link
Contributor

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version [x]
  • Used the search feature to ensure that the bug hasn’t been reported before [x]

Describe the bug
In the following structure:

<video loop="loop" autoplay="" playsinline="" muted="" aria-hidden="true" id="" preload="none" src="video-1.mp4">
<source type="video/mp4" src="video-2.mp4">
</video>

The beacon is picking video-2.mp4 as the LCP element.
It's caused by the following fall back (source ? source.src : '') here:

if (nodeName === "video") {
	element_info.type = "img";
	const source = element.querySelector('source');
	element_info.src = element.poster || (source ? source.src : '');
	element_info.current_src = element_info.src;
}

The beacon will initially look for the poster attribute. If not found, and if there is a nested source, it will pick src.

The only exploitable image on a video tag is the poster. And it only works for the video tag for now.

There is no need to look on nested source elements as they won't have a poster, at least until the related proposal comes to life whatwg/html#4004 (comment)

To Reproduce
Same as above.

Expected behavior
Assessing video tags should be limited to the poster attribute.

Screenshots
N/A

Additional context
https://secure.helpscout.net/conversation/2624385201/497095/

Acceptance Criteria (for WP Media team use only)
Clear instructions for developers, to be added before the grooming

@piotrbak piotrbak added the lcp label Jun 18, 2024
@piotrbak piotrbak added the type: enhancement Improvements that slightly enhance existing functionality and are fast to implement label Jul 3, 2024
@piotrbak piotrbak added module: OCI Optimize Critical Images priority: low Issues that can wait and removed lcp labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: OCI Optimize Critical Images priority: low Issues that can wait type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

No branches or pull requests

2 participants