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

🐛 Update preconnects in amp-youtube component #39903

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

westonruter
Copy link
Member

I just analyzed the resources which are loaded in a YouTube embed and they include:

  • fonts.gstatic.com (for the fonts used in the title)
  • yt3.ggpht.com (for the channel logo)
  • i.ytimg.com (for the poster image)
  • www.youtube.com (for JS and CSS assets)
  • www.gstatic.com (for more JS assets)

Notably, s.ytimg.com is not among the domains that resources are loaded from, although it is still being preconnected to:

preconnect.url(ampdoc, this.getVideoIframeSrc_());
// Host that YT uses to serve JS needed by player.
preconnect.url(ampdoc, 'https://s.ytimg.com', opt_onLayout);
// Load high resolution placeholder images for videos in prerender mode.
preconnect.url(ampdoc, 'https://i.ytimg.com', opt_onLayout);

I suggest removing this preconnect and instead replace it with a preconnect to fonts.gstatic.com since it is used to render the title text which is the actual LCP element (since the poster background image is excluded based on the current LCP heuristics).

@erwinmombay
Copy link
Member

thanks @westonruter

@erwinmombay
Copy link
Member

re-running jobs so we can merge

@erwinmombay
Copy link
Member

@westonruter do you mind rebasing and re-pushing, ill try and get the tests green but i can seem to retrigger the bundle size to get it to pass

@westonruter westonruter force-pushed the update/amp-youtube-preconnects branch from db0b27f to 79d88b3 Compare March 26, 2024 00:14
@westonruter
Copy link
Member Author

@erwinmombay done, although I've also updated it to just remove the preconnect for fonts.gstatic.com. I found that no assets from that domain are loaded at all when emulating a mobile device. Fonts are only loaded on desktop. Since most AMP pages are served to mobile, it's probably best to just omit the fonts preconnect.

@erwinmombay erwinmombay merged commit c6e23b1 into main Mar 26, 2024
52 checks passed
@erwinmombay erwinmombay deleted the update/amp-youtube-preconnects branch March 26, 2024 16:44
@erwinmombay
Copy link
Member

@westonruter merged

TribooAnalytics pushed a commit to TribooAnalytics/amphtml that referenced this pull request Apr 3, 2024
* Update preconnects in amp-youtube component

* Remove preconnect to Google Fonts since not on mobile
eszponder pushed a commit to krzysztofequativ/amphtml that referenced this pull request Apr 22, 2024
* Update preconnects in amp-youtube component

* Remove preconnect to Google Fonts since not on mobile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants