npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tubeplayer

v0.4.0

Published

TubePlayer — YouTube Popup Player. Custom YouTube popup player library with fully custom controls, mobile optimization, and no YouTube UI.

Downloads

518

Readme

TubePlayer — Custom YouTube Player Library

English | 한국어

npm version npm downloads license demo GitHub Sponsors

Embed YouTube videos the way you want — not the way YouTube wants.

TubePlayer completely replaces the default YouTube UI with your own custom controls. Use it as a popup layer with animations and dim overlay, or embed inline directly on the page — no popup needed.

Live Demo →

Why TubePlayer?

Drop a YouTube video anywhere on your page — popup or inline — with a fully branded experience in under 5 minutes.

  • Your brand, not YouTube's — Completely hides YouTube's logo, controls, and end-screen suggestions.
  • Popup or Inline — Open in a focused overlay layer, or embed directly in any container element.
  • Works everywhere — Framework-agnostic Vanilla JS. React, Vue, plain HTML — it just works.
  • Mobile-first — Swipe-to-close, touch-optimized controls, and flawless fullscreen on every device.
  • Zero dependencies — No jQuery, no lodash, no bloat. Pure ES Modules at ~7 kB gzipped.
  • Declarative setup — Add data-tube-* attributes to your HTML and call TubePlayer.init(). Done.

Features

Popup & UX

  • Smooth popup layer with dim overlay, focus trap, and 3 animations (Fade / Slide / Zoom)
  • Close on ESC, dim click, or swipe down (mobile)
  • Remembers volume and mute state across visits via localStorage
  • Playback always restarts cleanly when the layer is reopened

Inline Player

  • Embed the player directly on the page with data-tube-inline
  • No popup, no overlay — the video lives in your layout
  • Supports all the same options: controls, loop, start time, poster, and more
  • Control bar hides during playback and reappears on hover
  • No-interaction mode (data-tube-no-interaction) — removes all controls and disables click-to-play; ideal for background or decorative video

Playback Control

  • Custom control bar: play/pause, seek bar, time display, mute, volume slider, fullscreen, speed, YouTube link
  • Playback speed cycling: 0.5× → 0.75× → 1× → 1.25× → 1.5× → 2×
  • Set a start time (data-tube-start), loop playback (data-tube-loop), or auto-close on video end (data-tube-close-on-end)
  • Full keyboard shortcuts — Space, M, F, ←/→ (auto-hidden on touch devices)

Customization

  • Custom poster image to replace the YouTube thumbnail
  • CSS variable-based theme system — one line to apply your brand color
  • Fully declarative via data-tube-* HTML attributes or JavaScript API

Developer Experience

  • ESM / CJS / UMD bundle formats — works in any environment
  • TypeScript type definitions included
  • Lightweight: ~7 kB gzipped (core)

Installation

npm

npm install tubeplayer

CDN

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tubeplayer/dist/style.css">
<!-- JS (UMD) -->
<script src="https://cdn.jsdelivr.net/npm/tubeplayer/dist/tubeplayer.umd.js"></script>

Quick Start

Popup Mode

Open the video in a focused overlay layer.

<!-- Trigger button -->
<button data-tube-open="demo-layer">Watch Video</button>

<!-- Layer + player declaration -->
<div data-tube-layer="demo-layer"
     data-tube-close-on-dim="true"
     data-tube-animation="fade">
  <div data-tube-youtube="jNQXAC9IVRw"
       data-tube-autoplay="true"
       data-tube-theme="dark"
       data-tube-controls="mute,fullscreen">
  </div>
</div>

<script type="module">
  import TubePlayer from 'tubeplayer';
  TubePlayer.init();
</script>

Inline Mode

Embed the player directly on the page — no popup required.

<div data-tube-inline="jNQXAC9IVRw"
     data-tube-theme="dark"
     data-tube-controls="play,progress,time,mute,volume,fullscreen"
     data-tube-autoplay="false">
</div>

<script type="module">
  import TubePlayer from 'tubeplayer';
  TubePlayer.init();
</script>

JavaScript API

import TubePlayer, { TubeLayer, TubeYouTube } from 'tubeplayer';

TubePlayer.init({ theme: 'dark' });

// Popup: open/close programmatically
const instance = TubePlayer.get('demo-layer');
instance.open();
instance.on('video:play', () => console.log('playback started'));
instance.on('video:end',  () => console.log('playback ended'));

// Inline: control the player directly
const player = TubePlayer.getPlayer('my-inline-id');
player.play();
player.pause();

Data Attributes

Layer (data-tube-layer) — Popup mode

| Attribute | Description | Default | |---|---|---| | data-tube-layer | Unique layer ID | (required) | | data-tube-close-on-dim | Close when dim overlay is clicked | true | | data-tube-close-on-esc | Close on ESC key | true | | data-tube-animation | Animation type (fade, slide, zoom) | fade |

Player attributes

Use data-tube-youtube inside a [data-tube-layer] for popup mode. Use data-tube-inline as a standalone element for inline mode. All other attributes below apply to both modes.

| Attribute | Description | Default | |---|---|---| | data-tube-youtube | YouTube video ID (popup mode) | (required) | | data-tube-inline | YouTube video ID (inline mode) | (required) | | data-tube-autoplay | Auto-play on open | true (popup) / false (inline) | | data-tube-muted | Start muted | false | | data-tube-theme | Theme (dark) | dark | | data-tube-controls | Controls to show, comma-separated | mute,fullscreen | | data-tube-start | Start time in seconds | 0 | | data-tube-loop | Loop video | false | | data-tube-poster | Custom poster image URL | YouTube thumbnail | | data-tube-close-on-end | Auto-close layer when video ends (popup only) | false | | data-tube-no-interaction | Disable all controls and click-to-play/pause (inline only) | false |

Available control keys: play, progress, time, mute, volume, fullscreen, speed, youtube-link

Keyboard Shortcuts (Desktop)

| Key | Action | |---|---| | Space | Play / Pause | | Esc | Close layer (popup only) | | M | Toggle mute | | F | Toggle fullscreen | | / | Seek ±5 seconds |

Theme Customization

Override CSS variables to apply brand colors.

TubePlayer.init({
  theme: {
    '--tube-dim-bg': 'rgba(10, 10, 30, 0.9)',
    '--tube-control-color': '#e0e0ff',
  }
});

Build & Deploy

npm run dev        # Local dev server with demo
npm run build      # Build static demo site for Vercel
npm run build:lib  # Build library files for npm (dist/)
npm run test       # Run Vitest unit tests

Browser Support

Chrome, Firefox, Safari, Edge (latest 2 versions). Fully optimized for mobile.

License

MIT