Defer Parsing of Javascript in Youtube embed not working

Hello,

I tried to defer parsing of Javascript for emebdeded youtube. It is not working.
This code didn’t work:
<script> function init() { var vidDefer = document.getElementsByTagName('iframe'); for (var i=0; i<vidDefer.length; i++) { if(vidDefer[i].getAttribute('data-src')) { vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src')); } } } window.onload = init; </script>
Any idea?

Hi There,

Thanks for writing in! Can you just try adding your Javascript code into a Classic Raw Element in Cornerstone, at the bottom of the page and see if that helps.

Thanks!

Hi.

I am using X PRO editor

I solved it but i put the code in JSV editor. Is there another way?

Try using the Class Raw Element. If your method works though, you can use that.

Thanks.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.