常用的script标签:defer和async
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari Basic support 1.0 1.0 (1.7 or earlier) (Supported) (Supported) (Supported) async attribute (Supported) 3.6 (1.9.2) 10 – (Supported) defer attribute (Supported) 3.5 (1.9.1) 4 – (Supported) 执行时刻 There are three possible modes that can be selected using these attributes. If the async attribute is present, then the script will be executed asynchronously, as soon as it is available. If the async attribute is not present but the defer attribute is present, then the script is executed when the page has finished parsing. If neither attribute is present, then the script is fetched and executed immediately, before the user agent continues parsing the page. 简单的来说,使用这两个属性会有三种可能的情况 如果async为true,那么脚本在下载完成后异步执行。 本文another链接:http://feifeipan.sinaapp.com/?p=51 =====华丽丽的分割线========= 对于znxds提出的IE下的工作,我针对FF和IE6、IE7、IE8下面做了比较。 demo
Firefox中,inline的defer是没有效果的;outer的defer会在页面最底部执行。 IE8.0中,inline和outer的defer是起作用的,都会延迟到页面底部,排在其他非defer的js后面执行
IE7.0的情况,和IE8.0一致。
IE6.0中,关于defer inline js,要区分是在head中还是在body中。在head中defer inline js会在遇到body之后优先 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |