YouTube provides privacy enhanced mode for embedded videos to avoid loading any tracking cookies. This can be configured when you get the embed like from YouTube. This way you don't have to worry about cookie consent:


<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/NHEaYbDWyQE" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>


Another way would be to load YouTube embed video using inline javascript code which will honor the cookie preferences:


<div id="ytplayer">You must enable analytical cookies to watch this video</div>
<script type="text/plain" data-consent="analytics">
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'NHEaYbDWyQE'
});
}
</script>