Skip to content

Instantly share code, notes, and snippets.

@skywind3000
Last active May 8, 2019 16:03
Show Gist options
  • Save skywind3000/ef6ade267de146ccbbaaed292fc2c69c to your computer and use it in GitHub Desktop.
Save skywind3000/ef6ade267de146ccbbaaed292fc2c69c to your computer and use it in GitHub Desktop.
[javascript] async load script #js #async
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?430525c455fa119f047f66ba9aa5e3b1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
var script = document.createElement('script');
script.src = 'xxxxxxxxxxxxxxxx.viz.js'; // 加载脚本路径
script.onload = function(){
// 代码。。。。
};
// 在头部插入 script
var head = document.getElementsByTagName('head')[0];
head.appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment