Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
90 views
in Technique[技术] by (71.8m points)

javascript - How to load a script tag on a timer

The title is self explanatory, i would like to load the below script tag after 3 seconds has passed or on the window.load callback. This is because it takes too long to long this script even with async and defer.

I have tried document.write but it throws an error stating : Uncaught TypeError: Cannot read property 'insertBefore' of null

Any help would be appreciated! Thanks.

<script id="cid0020000272452409358" defer data-cfasync="false"  src="//st.chatango.com/js/gz/emb.js" style="width: 200px;height: 300px;">{"handle":"genoanime","arch":"js","styles":{"a":"333399","b":100,"c":"FFFFFF","d":"FFFFFF","k":"333399","l":"333399","m":"333399","n":"FFFFFF","p":"10","q":"333399","r":100,"pos":"br","cv":1,"cvfnt":"Verdana, Geneva, sans-serif, sans-serif","cvbg":"333399","cvw":150,"cvh":30,"ticker":1}}</script>
question from:https://stackoverflow.com/questions/65894766/how-to-load-a-script-tag-on-a-timer

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...