As in the title - how to delay JS script execution? I’ve already tried to use a few different versions of “the defer” function, using the code below (all placed right before the tag):
(or just defer></script) ending)
or
None of them seem to work, as they’re still appearing in the page speed insights as render-blocking, and as JS that is executed before all the important LCP components. And btw - all JS scripts I need to delay are in form of a link i.e “cdn.shopify.com/assets/458454854994.en.js” - something like that. So I don’t have them in form of a file i.e “base.js”.
I’ve also tried using Google’s code for exactly that (meaning loading text and images first and executing JS once they finish loading) :
<script
$(window).on("load, function () {
$(“body”).append(“
And I get an error 404 for this piece of code. As for the defer scripts above - I don’t get an error, but the transfer size of the particular JS script link almost doubles, and then the page slows down even more.