Loading Youtube Iframe API with RequireJS

Posted by davidgnin on Stack Overflow See other posts from Stack Overflow or by davidgnin
Published on 2012-10-11T15:59:22Z Indexed on 2012/10/13 3:37 UTC
Read the original article Hit count: 294

Filed under:
|
|

I'm trying to use the Youtube Iframe API inside a module definded with Require JS. As this API is loaded async and calls a function once is loaded, I used a requireJS plugin called "async", that worked before with google maps api.

However, this time something isn't working. My module starts this way: define(['text!fmwk/widgets/video/video.html','fmwk/utils/browser','async!http://www.youtube.com/iframe_api'], function (videoTpl,root) { ... });

and chrome console fires this error: Uncaught Error: Load timeout for modules: async!http://www.youtube.com/iframe_api_unnormalized3,async!http://www.youtube.com/iframe_api http://requirejs.org/docs/errors.html#timeout

If I don't use async plugin the object YT or its functions are undefinded, and the same happens if I download the API code. The API is loaded sometimes if I put an script tag in the head tag of the html file. All this is expected, but I don't understand because async plugin fails.

Thank you for your attention and help :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about youtube-api