youtube api js-code that you attach to the page, use the global context. You can put your code in
$(document).ready(function(){ window.onYouTubeIframeAPIReady = onYouTubeIframeAPIReady; });
But in the end you should write this line (*).
After that, the onYouTubeIframeAPIReady function will be accessible from the global context.
Danila
source share