[SOLVED] YT is not defined - Uncaught ReferenceError: [youtube api]

Post

Posted
Rating:
#4714 (In Topic #951)
Hello,

When logged in as admin on my site I kept getting a friendly nag error for admins about 

YT is not defined - Uncaught ReferenceError: [youtube api]

I have a youtube video embedded on my start page…. Everything worked ok but to fix the error I added:
 
<script src="https://www.youtube.com/player_api"></script>

into the HEAD template

and now no error :)

 

Post

Posted
Rating:
#4715
update:

while no error pops up, i have a new one in the browser console:

Error("The YouTube player is not attached to the DOM.")

the video still works and not sure if i should worry about this, or remove my script from the HEAD….

everything works & looks good either way

Post

Posted
Rating:
#4716
Assuming the embed is a Composr YouTube media embed, that's strange. The JS code relating to the YouTube player is only called once the YT player's JavaScript is loaded. Maybe there's some weird fringe situation like it loading across different frames or deloading when initialised in a tooltip - as I doubt the YouTube video from your home page would show on the dashboard except in some kind of content preview fashion.

Here's a speculative fix:
https://github.com/ocproducts/composr/commit/434999ae0608f8dfc055cf896b615b670a185d36
0 guests and 0 members have recently viewed this.