Javascript run inline script after load async resources

后端 未结 2 773
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 04:42

when I test page by optimizer, it suggest me use async for all CDN sources what I use.

To run any script I use

(function(){})();

I use a

2条回答
  •  醉酒成梦
    2020-12-18 05:33

    If I understood your problem correctly, you want to run inline script when the async script tag is loaded.

    You can use onload event of the script tag.

    function runInline() {
      console.log('inline script run')
    }

提交回复
热议问题