哪些浏览器支持 <script async="async"/>? [英] Which browsers support <script async="async" />?
问题描述
2009 年 12 月 1 日,Google 宣布支持 异步 Google分析跟踪.
On December 1, 2009, Google announced support for asynchronous Google Analytics tracking.
使用 标签的 async 指令实现异步跟踪.
The asynchronous tracking is achieved using the async directive for the <script>
tag.
哪些浏览器支持异步指令(<script async="async"/>
)以及从哪个版本开始?
Which browsers support the async directive (<script async="async" />
) and since which version?
推荐答案
google 指定的异步支持是通过两部分实现的:
The async support as specified by google is achieved using two parts:
在您的页面上使用脚本(该脚本由谷歌提供)写出一个 <script>标记到 DOM.
using script on your page (the script is supplied by google) to write out a <script> tag to the DOM.
该脚本具有 async="true" 属性,可向兼容浏览器发出信号,表明它可以继续呈现页面.
that script has async="true" attribute to signal to compatible browsers that it can continue rendering the page.
第一部分适用于不支持 <script async..
标签的浏览器,允许它们通过hack"(虽然非常可靠)加载异步,并且还允许渲染页面无需等待 ga.js 被检索.
The first part works on browsers without support for <script async..
tags, allowing them to load async with a "hack" (although a pretty solid one), and also allows rendering the page without waiting for ga.js to be retrieved.
第二部分只影响理解 async html 属性的兼容浏览器
The second part only affects compatible browsers that understand the async html attribute
- FF 3.6+
- FF 安卓所有版本
- IE 10+(从预览版 2 开始)
- Chrome 8+
- Android 版 Chrome 所有版本
- Safari 5.0+
- iOS Safari 5.0+
- Android 浏览器 3.0+(蜂窝向上)
- Opera 15.0+
- Opera Mobile 16.0+
- Opera Mini 无(从 8.0 开始)
- FF 3.6+
- FF for Android All Versions
- IE 10+ (starting with preview 2)
- Chrome 8+
- Chrome For Android All versions
- Safari 5.0+
- iOS Safari 5.0+
- Android Browser 3.0+ (honeycomb on up)
- Opera 15.0+
- Opera Mobile 16.0+
- Opera Mini None (as of 8.0)
指定异步的html5 正确"方式是使用 <script async src="..."
,而不是 <script async="true"
.但是,最初的浏览器不支持这种语法,也不支持在引用的元素上设置脚本属性.如果你想要这个,列表会改变:
The "html5 proper" way to specify async is with a <script async src="..."
, not <script async="true"
. However, initially browsers did not support this syntax, nor did they support setting the script property on referenced elements. If you want this, the list changes:
- FF 4+
- IE 10+(预览版 2 及更高版本)
- Chrome 12+
- Android 32+ 版 Chrome
- Safari 5.1+
- 没有安卓版本
这篇关于哪些浏览器支持 <script async="async"/>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!