Skip to content

Instantly share code, notes, and snippets.

View josetoledo8's full-sized avatar

José Roberto de Toledo josetoledo8

View GitHub Profile
@smhmic
smhmic / Listener - YouTube .gtm.tag.html
Last active November 8, 2022 15:52
Add YouTube JS API support for embedded YouTube videos
<script>(function(){
/*
This script is an alternative to the 'Add JavaScript API support to all YouTube videos'
setting in GTM's YT trigger. GTM's YT trigger will not load the YT API if no videos are
present at page load (it does add the enablejsapi param to dynanmically inserted videos,
but it will not load the YT API js). This script, on the other hand, should work in all cases.
*/
if( window.YT ) return;