JS异步加载的方式
方法一:Script Dom Element 1 2 3 4 5 6 7 8 (function(){ var scriptEle = document.createElement("script"); scriptEle.type = "text/javasctipt"; scriptEle.async = true; scriptEle.src = "http://cdn.bootcss.com/jquery/3.0.0-beta1/jquery.min.js"; var x = document.getElementsByTagName("head")[0]; x.insertBefore(scriptEle, x.firstChild); })(); <async>属性是HTML5中新增的异步支持。此方法被称为Script DOM Element方法 1 2 3 4 5 6 7 8 (function(){; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google