Last active
August 5, 2021 11:46
-
-
Save IgorGavrilenko/6a9b5cffec832d3fc2ddc1c6e6cc8889 to your computer and use it in GitHub Desktop.
отложенная загрузка скрипта
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
document.addEventListener("DOMContentLoaded", function (event) { | |
setTimeout(function () { | |
var resource = document.createElement('script'); | |
resource.async = "true"; | |
resource.src = ""; | |
var script = document.getElementsByTagName('script')[0]; | |
script.parentNode.insertBefore(resource, script); | |
}, 3000); | |
}); | |
var fired = false; | |
window.addEventListener('scroll', function () { | |
if (fired === false) { | |
fired = true; | |
setTimeout(function () { | |
}, 3000); | |
} | |
},{passive: true}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment