把行内脚本放置在样式表之后时,该行为会明显地延迟资源的下载。这个顺序导致只有当样式表下载完成并且行内脚本执行完毕时,后续资源才能开始下载
行内脚本要等样式表,后续资源要等行内脚本
<!doctype html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <script> function longCode() { var tStart = Number(new Date()); console.log(tStart); while ((tStart + 5000) > Number(new Date())) { } } //longCode(); // 忙指示 //setTimeout(longCode, 0); //setTimeout(longCode, 250); window.onload = longCode; </script> <img src="http://img.hb.aicdn.com/7b3e9e6d138160c071065d06654b08af90a1a2814f04-CldDGg_fw580" alt="" /> </body> </html>