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

amp-tiktok has layout shift #35789

Closed
westonruter opened this issue Aug 24, 2021 · 1 comment · Fixed by #35850
Closed

amp-tiktok has layout shift #35789

westonruter opened this issue Aug 24, 2021 · 1 comment · Fixed by #35850

Comments

@westonruter
Copy link
Member

westonruter commented Aug 24, 2021

Description

The amp-tiktok docs state:

Avoiding Layout shift

Prevent layout shift by matching the width and height attributes on the amp-tiktok element to the size of the video player.

By default, the width of the amp-tiktok iframe is 325px, resulting in a hight of roughly 575px. The default height of the embedded TikTok video player depends on the length and content of the TikTok caption. To show the entire video, the amp-tiktok component resizes to match the player height. You can avoid this by defining the width and height to match the video player.

I tried following this advice and obtaining the exact height of the element after the page has loaded:

<amp-tiktok height="721" layout="fixed-height" data-src="https://www.tiktok.com/@countingprimes/video/6988237085899574533"></amp-tiktok>

Nevertheless, there is layout shift that is happening when the video loads:

amp-tiktok-layout-shift.mov

While the page ends up with the same initial layout, there is a moment when the amp-tiktok grows too tall before shrinking back down.

Reproduction Steps

Try example on AMP Playground.

Relevant Logs

No response

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

2108052321001

@westonruter
Copy link
Member Author

@rebeccanthomas FYI: I did some more research into how layout shifting could be reduced based on the oEmbed response that TikTok provides. See this PR for the WordPress plugin which seems to make a pretty good estimation of the height by examining the length of the video description: ampproject/amp-wp#6586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants