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

Support high performance YouTube and Twitter embeds #191

Open
Swizec opened this issue May 18, 2021 · 2 comments
Open

Support high performance YouTube and Twitter embeds #191

Swizec opened this issue May 18, 2021 · 2 comments

Comments

@Swizec
Copy link

Swizec commented May 18, 2021

Hi,

YouTube and Twitter embeds hurt Lighthouse scores. Both load a bunch of unused JavaScript and create heavy iframe embeds.

I've built a custom transformer for YouTube that uses the lite-youtube facade embed (as recommended by Lighthouse). It uses a web component to render a preview image that turns into a full embed with user interaction.

I've also got a custom transformer that creates static Twitter embeds without client-side JavaScript. Uses the Twitter API to recreate tweets using static HTML and CSS.

You can see both in action here: https://serverlesshandbook.dev

The offer

Would contributing these to the core gatsby-remark-embedder plugin be desirable?

I think lite-youtube should be the default way this plugin embeds youtube.

Static Twitter I'm less sure of, but would love to find a way we can make it work.

If you think this is a good idea, I can make PRs :)

Cheers,
~Swizec

@bartveneman
Copy link

We could take it a step further and use https://swyxkit.netlify.app/faster-youtube-embeds instead, to avoid any JS cost.

@bartveneman
Copy link

Why do we need this?

I'm using a custom transformer for Youtube videos to render the above <iframe srcdoc="" />. This works excellent during a regular build, but apparently Gatsby's Deferred Static Generation can not cope with with Gatsby Plugins that do not have serializable config (like the shouldTransform and getHTML functions) and it throws a 500 error when visiting that page. (See this reduced test case).

Do you want to include any of the above mentioned alternatives in this library? Which one would you prefer? And would you accept a PR for that?

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

No branches or pull requests

2 participants