Skip to content

Instantly share code, notes, and snippets.

@Roy-Oto
Created May 10, 2021 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Roy-Oto/d1564c72f1344d6cd72f939e74a1748c to your computer and use it in GitHub Desktop.
Save Roy-Oto/d1564c72f1344d6cd72f939e74a1748c to your computer and use it in GitHub Desktop.
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