并行运行第三方javascript标记的简单解决方案?(“异步地”)?

并行运行第三方javascript标记的简单解决方案?(“异步地”)?,javascript,unobtrusive-javascript,Javascript,Unobtrusive Javascript,有什么简单的解决方案可以并行运行第三方javascript标记吗 html页面上只有几个脚本,不能一个接一个地加载/顺序加载 我知道对于广告来说,它是使用像doubleclick这样的ads服务器工作的,但这在这里是不必要的,不仅仅是广告 有些人需要能够分析html内容,如用户代理、ip、推荐人等 您可能非常了解的示例: 一, 四, var _gaq=_gaq | |[]; _gaq.push([''设置帐户','UA-12345-2']); _gaq.push([''u setDomai

有什么简单的解决方案可以并行运行第三方javascript标记吗

html页面上只有几个脚本,不能一个接一个地加载/顺序加载 我知道对于广告来说,它是使用像doubleclick这样的ads服务器工作的,但这在这里是不必要的,不仅仅是广告 有些人需要能够分析html内容,如用户代理、ip、推荐人等

您可能非常了解的示例:

一,


四,


var _gaq=_gaq | |[];
_gaq.push([''设置帐户','UA-12345-2']);
_gaq.push([''u setDomainName','website.edu']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?
'https://ssl' : 'http://www“)+”.goooogle analytics.com/ga.js”;
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
window.google\u analytics\u uacct=“UA-12345-2”;

加载外部JavaScript文件时,可以将
async
属性添加到脚本标记中


但是,脚本需要是自给自足的,并且不依赖于在脚本之前加载的其他代码。

无论您做什么(除了使用webworkers),Javascript都在一个线程中运行,这意味着它一次只执行一件事。耶,这真的很简单!:但它只适用于第一个示例?所有4个示例的解决方案是什么?不幸的是,即使是第一个示例也没有这样加载。我尝试使用最新的Firefox,第一个示例对您不起作用,可能还有其他原因。这些功能适用于所有现代浏览器。你能发布一个对你不起作用的真实网址吗?
<script src="http://another-ad-service.com/get-js.aspx?&cwadformat=728*90"</script>
<script language="JavaScript" type="text/javascript">
var 1a_account   = '12345';
var 1a_zonesize  = '12345-5';
var 1a_adtype    = 'js';
</script>
<script type="text/javascript" src="http://agency1a.somewhere/12345.js"></script>
<script type='text/javascript'>
<!--//<![CDATA[
   document.MAX_ct0 ='';
   var m3_u = (location.protocol=='https:'?'https://an-advertisment-agency.honolulu...'
   var m3_r = Math.floor(Math.random()*99999999999);
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("zoneid=12345");document.write("&amp;nodis=1");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : 
   (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if ((typeof(document.MAX_ct0) != 'undefined') && 
   (document.MAX_ct0.substring(0,4) == 'http')) {
       document.write ("&amp;ct0=" + escape(document.MAX_ct0));
   }
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'></scr"+"ipt>");
//]]>--></script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12345-2']);
  _gaq.push(['_setDomainName', 'website.edu']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ?
    'https://ssl' : 'http://www') + '.gooooogle-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
<script type="text/javascript"> window.google_analytics_uacct = "UA-12345-2"; </script>