Skip to content

Instantly share code, notes, and snippets.

@Roy-Oto
Created May 10, 2021
Embed
What would you like to do?
How to slow down the loading of iframes by adding Javascript
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment