feross / yt-player

Simple, robust, blazing-fast YouTube Player API
MIT License
678 stars 66 forks source link

Stupid question #68

Open ghost opened 3 years ago

ghost commented 3 years ago

As is it known YT Iframe API works on front-end. My question is: How can we use 'require' on front-end part? After a little search I found that it is suggested on Stack to use tool like Ender or Parcel. Is it yours implied ways to works with this npm? Let me know..

setalosas commented 3 years ago

You can use it with ES6 import this way:

import * as YTPlayer from '../wherever/feross-yt-player.js'
  ...
  const u2Player = new YTPlayer.YouTubePlayer(u2Frame$, playerApi.opts)
  ...

At least that's how I use it.

setalosas commented 3 years ago

I mean you don't have to use this needless Javascript infrastructure overcomplexities at all if you use ES6.

emahuni commented 10 months ago

use unpkg if you want to directly import in browser without bundlers inbetween

import YTPlayer from 'https://unpkg.com/yt-player@3.4.0/dist/yt.player.js'