youtube-video-element

Custom element (web component) for the YouTube player.

MIT 34 个版本
安装
npm install youtube-video-element
yarn add youtube-video-element
pnpm add youtube-video-element
bun add youtube-video-element
README

<youtube-video>

NPM Version NPM Downloads jsDelivr hits (npm) npm bundle size

A custom element for the YouTube player with an API that matches the <video> API.

Example

<script type="module" src="https://cdn.jsdelivr.net/npm/youtube-video-element@1"></script>
<youtube-video controls src="https://www.youtube.com/watch?v=rubNgGj3pYo"></youtube-video>

Installing

<youtube-video> is packaged as a javascript module (es6) only, which is supported by all evergreen browsers and Node v12+.

Loading into your HTML using <script>

Note the type="module", that's important.

Modules are always loaded asynchronously by the browser, so it's ok to load them in the head :thumbsup:, and best for registering web components quickly.

<head>
  <script type="module" src="https://cdn.jsdelivr.net/npm/youtube-video-element@1"></script>
</head>

Adding to your app via npm

npm install youtube-video-element --save

Or yarn

yarn add youtube-video-element

Include in your app javascript (e.g. src/App.js)

import 'youtube-video-element';

This will register the custom elements with the browser so they can be used as HTML.

版本列表
1.9.0 2026-02-18
1.8.1 2025-11-25
1.8.0 2025-11-13
1.7.0 2025-11-10
1.6.2 2025-08-08
1.6.1 2025-07-15
1.6.0 2025-07-02
1.5.3 2025-06-26
1.5.2 2025-06-26
1.5.1 2025-03-14
1.5.0 2025-03-12
1.4.0 2025-02-20
1.3.0 2024-12-19
1.2.0 2024-12-19
1.1.6 2024-06-14
1.1.5 2024-05-27
1.1.4 2024-05-26
1.1.3 2024-05-24
1.1.2 2024-05-17
1.1.1 2024-05-09
1.1.0 2024-05-08
1.0.1 2024-04-21
1.0.0 2023-09-15
0.2.2 2023-09-15
0.2.1 2023-09-15
0.2.0 2023-01-24
0.1.1 2023-01-19
0.1.0 2023-01-12
0.0.6 2021-12-23
0.0.5 2020-08-24
0.0.4 2020-08-24
0.0.3 2020-08-23
0.0.2 2020-08-23
0.0.1 2020-04-03