Created
September 28, 2014 11:01
-
-
Save DrMabuse23/48322a156b6061d6d40a to your computer and use it in GitHub Desktop.
load youtube js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onYouTubeIframeAPIReady() { | |
console.log( 'youtube api loaded' ); | |
$( document ).trigger('youtube-ready'); | |
} | |
requirejs( [ | |
'jquery' , | |
] , | |
function ( $ ) { | |
/** | |
* try to use this https://github.com/millermedeiros/requirejs-plugins/pull/39 | |
* but failed | |
*/ | |
function getYT() { | |
console.log('started'); | |
var tag = document.createElement( 'script' ); | |
tag.src = "https://www.youtube.com/iframe_api"; | |
var firstScriptTag = document.getElementsByTagName( 'script' )[ 0 ]; | |
firstScriptTag.parentNode.insertBefore( tag , firstScriptTag ); | |
} | |
$(function(){ | |
getYT(); | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment