<!--防止js阻塞html渲染。也防止js文件里面有操作dom时出错。-->
<!--属性defer IE8及以下使用的。 等 待dom加载完了才下载-->
<!--W3C html5属性,IE9及以上支持,写下属性async ,装逼用的。可以完整显示-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
console.log('111');
</script>
<!--写下属性async ,装逼用的。可以完整显示-->
</head>
<body>
<div id="">
</div>
<!--防止js阻塞html渲染。也防止js文件里面有操作dom时出错。-->
<!--属性defer IE8及以下使用的。 等 待dom加载完了才下载-->
<!--W3C html5属性,IE9及以上支持,写下属性async ,装逼用的。可以完整显示-->
<script src="js/utils.js" type="text/javascript" charset="utf-8" async="async"></script>
<script type="text/javascript">
function async_load() {
var s = document.createElement('script'),
oScript = document.getElementsByTagName('script')[0];
s.type = "text/javascript";
s.src = "js/utils.js";
s.async = true;
oScript.parentNode.insertBefore(s, oScript);
}
if (window.attachEvent) {
window.attachEvent('onload', async_load)
} else {
window.addEventListener('load', async_load, false);
}
function exec_util_width_loading_script(url, fn) {
var s = document.createElement('script'),
oScript = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
if (s.readyState) {
s.onreadystatechange = function() {
var state = s.readyState;
if (state === 'complate' || state === 'loaded') {
utils[fn]();
}
}
} else {
s.onload = function() {
}
}
s.scr = "utils.js";
oScript.parentNode.insertBefore(s, oScript);
}
exec_util_width_loading_script('utils.js','test');
</script>
</body>
</html>