Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-lite-youtube-embed

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-lite-youtube-embed

> A faster and cleaner YouTube embed component for React 1.4kB minified, 699B minified + gzipped

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40K
decreased by-47.41%
Maintainers
1
Weekly downloads
 
Created
Source

React Lite YouTube Embed

A faster and cleaner YouTube embed component for React 1.4kB minified, 699B minified + gzipped

Port of Paul Irish's Lite YouTube Embed to a React Component. Provide videos with a supercharged focus on visual performance. The gain is not the same as the web component of the original implementation but saves some requests and gives you more control of the embed visual. An "Adaptive Loading" way to handle iframes for YouTube.

Installation

Use your favorite package manager:

yarn add react-lite-youtube-embed
npm install react-lite-youtube-embed -S

Basic usage

import React from "react";
import { render } from "react-dom";
import { LiteYouTubeEmbed } from "react-lite-youtube-embed";

const App = () => (
  <div>
    <LiteYouTubeEmbed 
        id="L2vS_050c-M"
        title="What’s new in Material Design for the web (Chrome Dev Summit 2019)"
    />
  </div>
);

render(<App />, document.getElementById("root"));

And that's it.

Pro Usage

const App = () => (
  <div>
    <LiteYouTubeEmbed
       id="L2vS_050c-M" // Default none, id of the video or playlist
       adNetwork={true} // Default true, to preconnect or not to doubleclick addresses called by YouTube iframe (the adnetwork from Google)
       playlist={false} // Use  true when your ID be from a playlist
       poster="hqdefault" // Defines the image size to call on first render as poster image. Possible values are "default","mqdefault",  "hqdefault", "sddefault" and "maxresdefault". Default value for this prop is "hqdefault". Please be aware that "sddefault" and "maxresdefault", high resolution images are not always avaialble for every video. See: https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
       title="YouTube Embed" // a11y, always provide a title for iFrames: https://dequeuniversity.com/tips/provide-iframe-titles Help the web be accessible ;)
    />
  </div>
);

Bring Your Own Styles

React Lite YouTube Embed is packaged with all original styles from Paul Irish's Lite YouTube Embed but you can customize them as you wish passing as a prop.

const App = () => (
  <div>
    <LiteYouTubeEmbed
       id="L2vS_050c-M"
       activeClass="lyt-activated" // Default as "lyt-activated", gives control to wrapper once clicked
       iframeClass="" // Default none, gives control to add a class to iframe element itself
       playerClass="lty-playbtn" // Default as "lty-playbtn" to control player button styles
       wrapperClass="yt-lite" // Default as "yt-lite" for the div wrapping the area, it is the most important class and needs extra attention, please refer to LiteYouTubeEmbed.css for a reference.
    />
  </div>
);

Issues

Please feel free to open an issue!

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

TO DO:

  • Add tests
  • More iframe control

Thanks

Paul Irish (paulirish) for Lite YouTube Embed
Acauã Sperl de Faria (acaua) for code review
Addy Osmani (addyosmani) for the Adaptive Loading ideas

License

MIT

FAQs

Package last updated on 05 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc