question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

don't clobber an existing onYouTubeIframeAPIReady callback

See original GitHub issue

@feross great module! Love the simplicity of it.

The only issue I see right now is related to my particular use case: My code runs as a 3rd party library in someone else’s website. It’s possible that the hosting site already has a onYouTubeIframeAPIReady function declared. Would you be open to a PR which does something like this?

if (typeof window.onYouTubeIframeAPIReady !== 'function') {
      window.onYouTubeIframeAPIReady = () => {
        while (loadIframeAPICallbacks.length) {
          const loadCb = loadIframeAPICallbacks.shift()
          loadCb(null, window.YT)
        }
   }
} else {
   const previous = window.onYouTubeIframeAPIReady
   window.onYouTubeIframeAPIReady = () => {
     if (previous) {
        previous()
     }
     loadCb(null, window.YT)
   }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ferosscommented, Nov 5, 2020

This was released in 3.5.0

0reactions
mreinsteincommented, Jul 7, 2020

@feross let me know if you have any issues etc., happy to modify the PR as needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

YouTube IFrame API with existing IFrame failing to run callbacks
Best way to load a Youtube Video by his API, is following this sintaxis: <div id="video-youtube"></div> <script ...
Read more >
YouTube Player API Reference for iframe Embeds
The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Using the API's...
Read more >
gajus/youtube-player: YouTube iframe API abstraction. - GitHub
The downsides of using YouTube IFrame Player API are: Requires to define callbacks in the global scope ( window ). Requires to track...
Read more >
Getting going with the YouTube API | by richard bultitude
I do this within the onYouTubeIframeAPIReady callback so it only happens when the API is definitely ready. var YT;window.onYouTubeIframeAPIReady = function() {
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found