Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Youtube iframe embed: Uncaught ReferenceError: yt is not defined #151

Open
hammertimedk opened this issue Dec 31, 2013 · 14 comments
Open

Youtube iframe embed: Uncaught ReferenceError: yt is not defined #151

hammertimedk opened this issue Dec 31, 2013 · 14 comments

Comments

@hammertimedk
Copy link

I'm seeing this js error pop up sporadically (Chrome) and it's triggered by the line

$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");

I'm guessing this is when Fitvids wraps my iframe in some responsive magic, and the element then gets recreated on the page, or something like that? In any case, the only reference to this specific error I found online was: https://userscripts.org/topics/124302 - but that doesn't seem right as Fitvids doesn't seem to be referencing the yt variable/object in any way (neither does my code) - so I'm tempted to think this is a bug in Youtube's own js. Can't be sure though.

Here you can see it live (dev. site): http://skovstable.nes64.hammerti.me/

As mentioned, the error is sporadic and shows up rather randomly, so I'm also suspecting it has something to do with network/order of execution somewhere, which makes it even harder to pinpoint.

Anyhoo, here's hoping you've seen this before and know what this is all about :)

EDIT: Looked a bit closer and once Fitvids has done its thang, the iframe is loaded a second time (which makes sense). I'm thinking that sometimes, for some reason, the Youtube JS which the iframe contents depends on then sometimes doesn't get loaded/executed properly. Which may be a browser quirk, network problem at Youtube or simply crappy Youtube JS. Which basically means that Fitvids isn't responsible as such, except if there might be a way of wrapping the iframe with the Fitvids magic and not have the browser load the iframe twice?

@davatron5000
Copy link
Owner

What browsers is this in? IE?—
Sent from Mailbox for iPhone

On Tue, Dec 31, 2013 at 6:11 AM, hammertimedk [email protected]
wrote:

I'm seeing this js error pop up sporadically and it's triggered by the line
$this.wrap('

').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
I'm guessing this is when Fitvids wraps my iframe in some responsive magic, and the element then gets recreated on the page, or something like that? In any case, the only reference to this specific error I found online was: https://userscripts.org/topics/124302 - but that doesn't seem right as Fitvids doesn't seem to be referencing the yt variable/object in any way (neither does my code) - so I'm tempted to think this is a bug in Youtube's own js. Can't be sure though.
Here you can see it live (dev. site): http://skovstable.nes64.hammerti.me/
As mentioned, the error is sporadic and shows up rather randomly, so I'm also suspecting it has something to do with network/order of execution somewhere, which makes it even harder to pinpoint.

Anyhoo, here's hoping you've seen this before and know what this is all about :)

Reply to this email directly or view it on GitHub:
#151

@hammertimedk
Copy link
Author

Sry - Chrome - Ive edited the issue with a bit more info :-)
On 31 Dec 2013 13:31, "Dave Rupert" [email protected] wrote:

What browsers is this in? IE?—
Sent from Mailbox for iPhone

On Tue, Dec 31, 2013 at 6:11 AM, hammertimedk [email protected]
wrote:

I'm seeing this js error pop up sporadically and it's triggered by the
line
$this.wrap('

').parent('.fluid-width-video-wrapper').css('padding-top',
(aspectRatio * 100)+"%");
I'm guessing this is when Fitvids wraps my iframe in some responsive
magic, and the element then gets recreated on the page, or something like
that? In any case, the only reference to this specific error I found online
was: https://userscripts.org/topics/124302 - but that doesn't seem right
as Fitvids doesn't seem to be referencing the yt variable/object in any way
(neither does my code) - so I'm tempted to think this is a bug in Youtube's
own js. Can't be sure though.
Here you can see it live (dev. site):
http://skovstable.nes64.hammerti.me/
As mentioned, the error is sporadic and shows up rather randomly, so I'm
also suspecting it has something to do with network/order of execution
somewhere, which makes it even harder to pinpoint.
Anyhoo, here's hoping you've seen this before and know what this is all

about :)

Reply to this email directly or view it on GitHub:
#151


Reply to this email directly or view it on GitHubhttps://github.com//issues/151#issuecomment-31393305
.

@gubagu
Copy link

gubagu commented Feb 28, 2014

Same problem here. In IE 11 and chrome v33.0.17. It seems to be working ok in FF.

Cheers,
Guby

@davatron5000
Copy link
Owner

Any YouTube video on IE11 and Chrome 33? Example?

@gubagu
Copy link

gubagu commented Mar 1, 2014

Hey davatron5000,
Thanks for your fast reaction man !
The weird part is that i checked it today and the error is gone. So i suspect that there is some change in the google embed script. It was ok then it went for the error "yt not defined", and now is good again. At last as much as i can tell. I'll do more test and will share the outcome. I probably just jumped the gun. Thanks for sharing this plugin with us and keep up the good work.

Cheers,
Guby

@hammertimedk
Copy link
Author

I'm seeng this happen sporadically as well so that fits with what gubagu reports.

@davatron5000
Copy link
Owner

If anyone can get a reproducible reduced test case for this, I'll buy you a beer. I've seen it happen but haven't been able to diagnose. Seems irregular and catastrophic. Here are all the possible explanations:

  • CORS/CSP security sort of thing. Browsers flirt with different levels of this all the time.
  • YouTube failure (unlikely)
  • Plugin collisions with YouTube
  • Bad document standards modes (might explain older IEs)
  • Memory leak (for autoplaying videos)
  • jQuery's $.wrap() on an iFrame causes some bugs. Was fixed/updated in jQuery 1.9, I believe.

If it's the last one, we could just require a better version of jQuery.

@ian12sm
Copy link

ian12sm commented Mar 5, 2014

Having a similar issue here, embeds on our homepage are acting very sporadically in Chrome (Windows 8). Sometimes they'll work fine, other times it just loads a blank screen, other times there's no content at all.
Here's a link http://saraevans.12southdev.com/
Funny thing is its only on our homepage, the video page has been working fine. Videos appear fine in all other browsers too, just funky in chrome.

@davatron5000
Copy link
Owner

@ian12sm Blank screen? Hmmmm...

It looks like you haven't upgraded to FitVids 1.1.0, maybe that's the issue. I see in your scripts.min.js that the &shy; character isn't properly encoded and I wonder if that's what is causing the errors. No idea, but 1.1.0 fixes it, then maybe it was that (?!??)

@ian12sm
Copy link

ian12sm commented Mar 5, 2014

Will give these a try and come back with the results, thanks!

@bjorn-ali-goransson
Copy link

Could it be because the iframe sometimes hasn't loaded fully, and our call to fitVids is done on documentready? Maybe $(window).load(...) helps.

Experienced it once, first time I loaded my own page. No more...

@gubagu
Copy link

gubagu commented Mar 16, 2014

@bornemix
That wasn't the case with my set. I initilize the fitvids on window.load.

@LesAldridge
Copy link

I'm having a similar problem with YouTube embedded in a Bootstrap Modal window. It had been fine and then today, it started giving 'ytcfg is not defined' errors on page load, and on running the video. Using Chrome with Win8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants