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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nuxt-lazytube

v0.2.1

Published

Nuxt.js 3 nuxt-lazytube

Downloads

608

Readme

Embed a YouTube or Vimeo player easily and lazy load the video to save resources and reduces initial load size. Useful when performance and page size is important or for sites with many embedded videos.

For a simple example page with 10 videos, nuxt-lazytube will reduce loadtime by 7x and memory usage by 2-3x.

npm version GitHub License npm downloads Nuxt nuxt-feather-icons Static Badge

Demo online


Table of Content

Features

  • reduces initial load size by ~1.1 MB per video
  • fully responsive and customizable through props
  • provides methods to control (play, stop, pause and reset) embedded videos
  • provide options to set up custom title and preview of embedded videos
  • platform supported: Youtube and Vimeo

Demo

view nuxt-lazytube

Setup

Installation

nuxt-lazytube for Nuxt3 applications.

$ npx nuxi@latest module add nuxt-lazytube

Config

nuxt.config.js

{
     modules: [
        'nuxt-lazytube',
    ]
},

Usage

<template>
    <!-- Youtube Embed -->
    <LazyYoutube src="https://www.youtube.com/watch?v=TcMBFSGVi1c"/>

    <!-- Vimeo Embed -->
    <LazyVimeo src="https://player.vimeo.com/video/64654583"/>
</template>

API

Props

| Name | Type | Default Value | Description | Required | |--------------------|-----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | src | String | | To load video and iframe, should be Youtube/Vimeo video link. | `true` | | `aspectRatio` | `String` | `16:9` | Maintaining the aspect ratio of video, perfect for responsively handling video embeds based on the width of the parent, should be in `*:*` format. e.g, `1:1`, `4:3`, `16:9` and `21:9`. | `false` | | `maxWidth` | `String` | `560px` | Defines maximum width of video container. | `false` | | `showTitle` | `Boolean` | `true` | Defines whether to show video title on top. | `false` | | `autoplay` | `Boolean` | `false` | Defines whether to load the iframe as the page loads _(not recommended)_ | `false` | | `thumbnailQuality` | `String` | `standard` | Defines the quality of thumbnail, should be one of the following `default`, `medium`, `high`, `standard` or `maxres` | `false` | | `iframeClass` | `String` | `ly-iframe` | Defines the class on iframe element | `false` | | `customTitle` | `String` | | Defines the custom title of the video | false | | customThumbnail | String | | Defines the custom thumbnail image link of the video | `false` | | `iframePolicy` | `String` | | Define iframe in COEP environments ['anonymous' or 'credentialless']. | false |

Slots

This Component provides some slots. You can use the named slot to render custom play button and loader:

| Slot | Description | |--------|-----------------------------------------------------| | button | Slot gives an ability to provide custom play button | | loader | Slot gives an ability to provide custom loader |

Methods

These methods let you control the player using JavaScript, so you can perform the operations like play, stop, pause and reset.

The user's browser must support the HTML5 postMessage feature. Most modern browsers support postMessage.

| Name | Type | Usage | |------------|------------|-------------------------------------------| | playVideo | function | this.$refs["lazyVideo"]['playVideo']() | | stopVideo | function | this.$refs["lazyVideo"]['stopVideo']() | | pauseVideo | function | this.$refs["lazyVideo"]['pauseVideo']() | | resetView | function | this.$refs["lazyVideo"]['resetView']() |

Note: Must Replace lazyVideo with your ref.

Example


<script setup>
    const lazyVideo = ref()

    const handleClick = (event) => {
        lazyVideo.value[event]()
    }
</script>

<template>
    <div>
        <LazyYoutube
                ref="lazyVideo"
                src="https://www.youtube.com/embed/KfYkzXTut1Y"
        />

        <button @click="handleClick('playVideo')">Play</button>
        <button @click="handleClick('stopVideo')"> Stop</button>
        <button @click="handleClick('pauseVideo')"> Pause</button>
        <button @click="handleClick('resetView')"> Reset</button>
    </div>
</template>

⚖️ License

Released under MIT by @4slan.