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

@art_is_code/smart_video

v1.1.1

Published

Smart, GDPR-compliant video embedder. Blocks iframes (YouTube, TikTok, Instagram, etc.) until consent is given.

Readme

@art_is_code/smart_video

npm version

Smart, GDPR-compliant video embedder. It blocks 3rd-party iframes (YouTube, TikTok, Instagram, etc.) until consent is given and provides lazy loading.

🚀 Key Features

  • Privacy-First: Uses youtube-nocookie.com and Vimeo dnt=1 by default.
  • Lazy Loading: High performance. Scripts load only when needed.
  • Universal Logic: Works via raw URLs. No messy iframe code required.
  • Future-Proof: Easily update regex patterns if platforms change their URL structure.

📦 Installation

Via npm

npm install @art_is_code/smart_video

Then import it in your JavaScript module:

import { SmartVideo } from '@art_is_code/smart_video';

Via CDN (Direct Browser Usage)

<script type="module">
    import { SmartVideo } from 'https://unpkg.com/@art_is_code/smart_video/dist/smart_video.min.js';
    
    const myVideo = new SmartVideo();
</script>

🧱 HTML Structure

Simply place a div with the data-aic-video attribute. The library will handle the rest based on the URL provided.

<div data-aic-video="[https://www.youtube.com/watch?v=dQw4w9WgXcQ](https://www.youtube.com/watch?v=dQw4w9WgXcQ)"></div>

🎨 CSS & Layout (Container-First)

"SmartVideo uses a Container-First approach. The module will fill 100% of its parent. We recommend using aspect-ratio to prevent Layout Shifts (CLS) during activation."

[data-aic-video] {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9; /* Default for YouTube/Vimeo */
    background: #000;
}

[data-aic-video].vertical {
    aspect-ratio: 9 / 16; /* For TikTok/Reels */
    max-width: 350px;
}

⚙️ Configuration Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | selector | string | '[data-aic-video]' | CSS selector used to identify video containers. | | lang | string | 'en' | Active language code for placeholder messages. | | consent | object | {youtube:false, ...} | Initial consent state for each supported provider. | | translations | object | {en:{...}} | Dictionary containing translation strings for each language. | | providers | object | {youtube:{...}, ...} | Definitions of regex patterns and embed logic for vendors. |

🛠 Usage

With @art_is_code/privacy_js (GDPR Mode)

Ideal for full compliance. It synchronizes with the global privacy banner.

const myVideo = new SmartVideo({
    consent: { youtube: myPrivacy.hasConsent('youtube') }
});

// Re-sync when privacy settings change
window.addEventListener('artIsPrivacyUpdated', () => {
    window.dispatchEvent(new CustomEvent('aicVideoUpdate', { 
        detail: { youtube: myPrivacy.hasConsent('youtube') }
    }));
});

Standalone

// Use this if you don't have a global privacy manager. 
// It captures the click on the "Accept" button and unlocks the video instantly.
window.addEventListener('aicRequestConsent', (e) => {
    const { vendor } = e.detail;
    const consentUpdate = {};
    consentUpdate[vendor] = true;

    window.dispatchEvent(new CustomEvent('aicVideoUpdate', { 
        detail: consentUpdate 
    }));
});

🔌 Custom Providers

The library is agnostic. If a new platform emerges, just add a regex and an extraction rule:

const myVideo = new SmartVideo({
    providers: {
        newplatform: {
            pattern: /new-service\.com/,
            getEmbed: (url) => {
                const id = url.split('/').pop(); // Extract ID
                return `https://www.new-service.com/embed/${id}`;
            }
        }
    }
});

📡 Events

SmartVideo communicates via standard DOM Events. You can trigger or listen to them from anywhere in your app.

| Event | Direction | Description | | :--- | :--- | :--- | | aicRequestConsent | OUT | Fired when a user clicks the "Accept" button. Payload: { detail: { vendor, element } }. | | aicVideoUpdate | IN | Send this to update consent states and refresh videos. Payload: { detail: { youtube: true, ... } }. |

👁️ Live Demo

📜 License

This project is licensed under the MIT License - see the LICENSE file for details. MIT © Andrea D'Agostino (art is code)