Thread:Project:Support desk/Can JavaScript be used on a wiki page in order to access the YouTube API?/reply

You can only add JS inline in a page if $wgRawHtml is true. Allowing JS to be added by anyone is a security risk, because then anyone could control the browser of whomever visits the page.

Admins can add JS to mediawiki:Common.js (However that js is loaded on every page, and is loaded after the page load event, so document.write cannot be used there).

Ideally for this sort of thing you'd want to find someone who has written a youtube api extension for MediaWiki. Unfortunatly I don't think anyone has.