我正在使用以下代码允许在我的网站上并行下载 JavaScript
var head = document.getElementsByTagName("head")[0];
var sTag1 = document.createElement("script");
sTag1.type = sTag1.type = "text/javascript";
sTag1.src = "http://example.com/one.js";
var sTag2 = document.createElement("script");
sTag2.type = sTag2.type = "text/javascript";
sTag2.src = "http://example.com/two.js";
var sTag1 = document.createElement("script");
sTag3.type = sTag3.type = "text/javascript";
sTag3.src = "http://example.com/three.js";
head.appendChild(sTag1);
head.appendChild(sTag2);
head.appendChild(sTag3);
然而,使用 YSlow,它表明即使one.js
,two.js
和three.js
正在并行下载 - 直到最后一个 JavaScript 完全下载后,图像才会加载。
我可以做些什么来防止由于我的 JavaScript 文件下载而阻止加载图像。