Skip to content

This enables lazy loading of YouTube videos with a customizable play button and smooth transitions, enhancing page load times and user experience.

License

Notifications You must be signed in to change notification settings

nexoscreator/lazy-youtube-player

Repository files navigation

GitHub Pages GitHub Release GitHub License GitHub Code


🎥 Lazy YouTube Player

image

Lazy YouTube Player is a lightweight, customizable YouTube player. It provides a simple way to embed YouTube videos with lazy loading capabilities, improving your website's performance.


✨ Features

  • Lazy loading of YouTube videos using Intersection Observer API
  • TypeScript support for improved developer experience
  • Customizable player options (thumbnail, play button, etc.)
  • Accessibility improvements with ARIA attributes
  • Responsive design
  • Error handling for invalid video IDs or API failures

📥 Installation

Follow these steps to set up Lazy YouTube Player on your machine.

  1. Add the script to your HTML file:
<script type='module'
  src="https://cdn.jsdelivr.net/npm/[email protected]/yt-player.min.js"
  defer
></script>
  1. Add the stylesheet to your HTML file:
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/[email protected]/yt-player.min.css"
/>

🎯 Usage

Here's a basic example of how to use the Lazy YouTube Player in a website:

<div
  class="NexosYt"
  data-embed="YT_VIDEO_ID"
></div>

💡 You can also customize thumbnail data-thumbnail="CUSTOM_THUMBNAIL_URL", its optional.


🔗 Useful Links

Web Demo GitHub Repo YouTube Video NPM Package


🧠 API

The LazyYouTubePlayer component accepts the following props:

  • NexosYT (string, required): The YouTube Player Class.
  • videoId (string, required): The YouTube video ID.
  • thumbnailUrl (string, optional): Custom thumbnail URL. If not provided, the default YouTube thumbnail will be used.
  • width (number, optional): The width of the player. Default: 640.
  • height (number, optional): The height of the player. Default: 360.

🤝 Contributing

We ❤️ contributions! Follow these steps to contribute:

  1. 🍴 Fork the repository
  2. 🌿 Create a new branch (git checkout -b feature/AmazingFeature)
  3. 💾 Commit your changes (git commit -m 'Add some AmazingFeature')
  4. 🚀 Push to the branch (git push origin feature/AmazingFeature)
  5. 🔃 Open a Pull Request

📖 See our Contribution Guidelines for more details.


📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


📬 Contact & Community

💬 Join us on Discord: Click Here
🐦 Follow on Twitter: @nexoscreator
📧 Email: [email protected]

Created with ❤️ by @nexoscreator

⭐ Star us on GitHub!

About

This enables lazy loading of YouTube videos with a customizable play button and smooth transitions, enhancing page load times and user experience.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published