Youtube iframe api not triggering onYouTubeIframeAPIReady Youtube iframe api not triggering onYouTubeIframeAPIReady javascript javascript

Youtube iframe api not triggering onYouTubeIframeAPIReady


It is not a timeout issue, and you should not need to fire this function manually.

Make sure your onYouTubeIframeAPIReady function is available at the global level, not nested (hidden away) within another function.


You can always append it to the window object to make sure it is evoked globally. This is helpful if your code is using amd.

window.onYouTubeIframeAPIReady = function() {}


If you have to put in inside to a function, one possible solution isinstead of:

function onYouTubeIframeAPIReady() {  // func body...}

you can declare it like this:

window.onYouTubeIframeAPIReady = function() {  // func body...}

In this case make sure, that you insert the certain script to the dom after the declaration (the insertBefore() call what is in the global scope now in your case):