Be happy that you're providing a better user experience to your visitors
<!-- Include the CSS & JS.. (This could be direct from the package or bundled) --><linkrel="stylesheet" href="node_modules/lite-youtube-embed/src/lite-yt-embed.css" />
<scriptsrc="node_modules/lite-youtube-embed/src/lite-yt-embed.js"></script><!-- Use the element. You may use it before the lite-yt-embed JS is executed. --><lite-youtubevideoid="ogfYd705cRs" playlabel="Play: Keynote (Google I/O '18)"></lite-youtube>
Privacy note: lite-youtube uses youtube-nocookie.com instead of youtube.com in order
to be more privacy friendly for end users.
Custom Player Parameters
YouTube supports a variety of player parameters to control the iframe's behavior and appearance.
These may be applied by using the params attribute.
<!-- Example to show a video player without controls, starting at 10s in, ending at 20s, with modest branding *and* enabling the JS API --><lite-youtubevideoid="ogfYd705cRs" params="controls=0&start=10&end=30&modestbranding=2&rel=0&enablejsapi=1"></lite-youtube>
Note that lite-youtube uses autoplay=1 by default.
paulirish/lite-youtube-embed
Lite YouTube Embed
Provide videos with a supercharged focus on visual performance. This custom element renders just like the real thing but approximately 224× faster.
Demo: https://paulirish.github.io/lite-youtube-embed/
Comparison
<iframe>
YouTube embedlite-youtube
Basic usage
Use the
lite-youtube-embed
npm package or download from this repo and usesrc/
.To use the custom element you will need to:
lite-youtube
tag via HTML or JS.Privacy note: lite-youtube uses youtube-nocookie.com instead of youtube.com in order to be more privacy friendly for end users.
Custom Player Parameters
YouTube supports a variety of player parameters to control the iframe's behavior and appearance. These may be applied by using the
params
attribute.Note that lite-youtube uses
autoplay=1
by default.Demo: https://paulirish.github.io/lite-youtube-embed/variants/params.html
Pro-usage: load w/ JS deferred (aka progressive enhancement)
Use this as your HTML, load the script asynchronously, and let the JS progressively enhance it.
Demo: https://paulirish.github.io/lite-youtube-embed/variants/pe.html
Custom poster image
If you want to provide a custom poster image, just set it as the background-image, and lite-yt will not overwrite it:
Demo: https://paulirish.github.io/lite-youtube-embed/variants/custom-poster-image.html
Other fast YouTube embeds
justinribeiro/lite-youtube
ibrahimcesar/react-lite-youtube-embed
kylemocode/react-lite-yt-embed
andrewvasilchuk/vue-lazy-youtube-video
Other third-party facades
luwes/lite-vimeo-embed
slightlyoff/lite-vimeo
calibreapp/react-live-chat-loader
danielbachhuber/intercom-facade/