All Projects → kylemocode → react-lite-yt-embed

kylemocode / react-lite-yt-embed

Licence: MIT license
React version of lite-youtube-embed iframe which render fast 🚀

Programming Languages

typescript
32286 projects
CSS
56736 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-lite-yt-embed

React Adal
Azure Active Directory Library (ADAL) support for ReactJS
Stars: ✭ 211 (+167.09%)
Mutual labels:  iframe
trainmanjs
TrainmanJS - Cross-Origin Communication Library
Stars: ✭ 16 (-79.75%)
Mutual labels:  iframe
PostEvent
A Cross-Domain Event Handler javascript library. Pure Vanilla JS, no dependencies.
Stars: ✭ 14 (-82.28%)
Mutual labels:  iframe
Lazyframe
🛀🏽 Dependency-free library for lazyloading iframes
Stars: ✭ 237 (+200%)
Mutual labels:  iframe
scion-microfrontend-platform
SCION Microfrontend Platform is a TypeScript-based open-source library that helps to implement a microfrontend architecture using iframes.
Stars: ✭ 51 (-35.44%)
Mutual labels:  iframe
react-responsive-embed
⚛️ Embed iframes responsively
Stars: ✭ 39 (-50.63%)
Mutual labels:  iframe
Iframe Resizer React
The official React interface for Iframe-Resizer
Stars: ✭ 183 (+131.65%)
Mutual labels:  iframe
vue-iframe-print
一款支持局部打印的 vue插件
Stars: ✭ 26 (-67.09%)
Mutual labels:  iframe
cdn
🚀 ✈️ 🚄 free CDN for everyone who wants to speed his website freely!😄
Stars: ✭ 16 (-79.75%)
Mutual labels:  iframe
Boundary
Boundary is a CSS+Javascript library for Chrome extension developers to easily create HTML elements that won’t affect or be affected by the current webpage’s CSS. Strongly recommended if you are considering adding a sticker, a sidebar or any overlay box using content script.
Stars: ✭ 59 (-25.32%)
Mutual labels:  iframe
get-css-data
A micro-library for collecting stylesheet data from link and style nodes
Stars: ✭ 29 (-63.29%)
Mutual labels:  iframe
pikaz-iframe
基于vue封装的iframe组件
Stars: ✭ 54 (-31.65%)
Mutual labels:  iframe
rx-postmessenger
Minimal RxJS adapter for the window.postMessage API for request-response streams and notification streams across frame windows.
Stars: ✭ 27 (-65.82%)
Mutual labels:  iframe
React Native Youtube Iframe
A wrapper of the Youtube-iframe API built for react native.
Stars: ✭ 221 (+179.75%)
Mutual labels:  iframe
oembed
A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.
Stars: ✭ 34 (-56.96%)
Mutual labels:  iframe
Penpal
A promise-based library for securely communicating with iframes via postMessage.
Stars: ✭ 197 (+149.37%)
Mutual labels:  iframe
Friendly Code Editor
Try this Friendly Code Editor. You'll love it. I made it with a lot of effort. It has some great features. I will update it adequately later. Very helpful for developers. Enjoy and share.
Stars: ✭ 20 (-74.68%)
Mutual labels:  iframe
jekyll-loading-lazy
🧙🏽‍♀️ Automatically adds loading="lazy" to <img> and <iframe> tags. Load images on your sites lazily without JavaScript.
Stars: ✭ 41 (-48.1%)
Mutual labels:  iframe
iframe-worker
A tiny WebWorker polyfill for the file:// protocol
Stars: ✭ 23 (-70.89%)
Mutual labels:  iframe
iframe-communication
Basic two way iframe communication
Stars: ✭ 88 (+11.39%)
Mutual labels:  iframe

React Lite YouTube Embed

React component version of lite-youtube-embed scaffolded with tsdx, which focus on visual performance, rendering just like the real thing but much faster.

FOSSA Status Download

Quick Start

Install

Please use version at least above @1.2.1, version below that is experimental and therefore may cause some runtime error.

react-lite-yt-embed

$ yarn add react-lite-yt-embed

or

$ npm install react-lite-yt-embed

Sandbox Example

codesandbox

Overview

Features 🎉

  • Preconnect YouTube domain while mouseover
  • Preload thumbnail image to improve user experience
  • WebP support, and fallback to jpg if the browser not support it
  • Provides many props which can customize frame behaviors
  • Lazy load support
  • Render fast, improve your web's performance

Introduction

'react-lite-yt-embed' is a react component version of popular package lite-youtube-embed, which can use in React project including SSR and CSR project. It renders just like the real iframe but way much faster.

Why is it faster than normal iframe ?

  • Preload the YouTube thumbnail image when page loaded. [Make image load faster]
  • Preconnect YouTube domain when mouse hover on the component. [Save 3 round-trip-time (DNS lookup + TCP handshake + SSL negotiation) before user click play button, making iframe load faster]

WebP Support (support after version @1.2.4)

'react-lite-yt-embed' support WebP image format, which is generally 25% - 35% smaller than jpg image, so the network request time will also decrease, making your web app render even faster.

If you use some browsers that not totally support WebP, for example, Safari, 'react-lite-yt-embed' will fallback the image to jpg automatically.

You can see WebP browser support here.

Basic Usage

import { LiteYoutubeEmbed } from 'react-lite-yt-embed';

// In your react component
<>
  <LiteYoutubeEmbed id={id}> {/* ID of YouTube video */}
  {/* You can add more props, see the description below. */}
  {/* You can also give the iframe an outer container */}
</>

Component Props

props required default value Type Description
id true none string The unique id of the youtube video
defaultPlay false false boolean Set defaultPlay as true will directly show youtube iframe
isPlaylist false false boolean If you want to play playlist, set this as true and pass the playlist id
noCookie false true boolean Use "https://www.youtube-nocookie.com" as path or "https://www.youtube.com"
mute false true boolean Set the video is mute or not.
params false {} Object<string, string> Query string params (autoplay and mute are default query string, you do not have to set them), the value have to be a string type.
isMobile false false boolean Use in mobile device or not.
mobileResolution false 'hqdefault' 'hqdefault' | 'sddefault' | 'maxresdefault' You can specify the resolution of the thumbnail image on the phone (default is hqdefault, which is a lower resolution).
desktopResolution false 'maxresdefault' 'hqdefault' | 'sddefault' | 'maxresdefault' You can specify the resolution of the thumbnail image on the desktop (default is maxresdefault, which is the highest resolution).
lazyImage false false boolean If true, set the img loading attribute to 'lazy', default is undefined.
imageAltText false "YouTube's thumbnail for this video." string You can specify an alternative text description for the thumbnail image for accessibility purposes.
iframeTitle false "YouTube video." string You can specify a title for the iframe containing the video for accessibility purposes.

Run on local development environment

  • Clone the repo
  • npm install | yarn install
  • Make your change or contribution
  • npm run build (in root folder)
  • cd in example folder & run npm install
  • npm run build (in example folder)
  • npm run start (in example folder)
  • visit localhost:1234 in the browser

Roadmap (Welcome contribution)

  • Testing
  • CI/CD pipeline

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].