我知道的事情:
-
如果脚本改变样式/内容,屏幕会闪烁(对我来说不是问题,因为我目前在页面末尾加载脚本,因此已经有了解决方法)
-
无法检测脚本加载失败(不太担心这一点,因为一切我的开发需要使用或不使用 javascript。可能会影响我对第 1 项的解决方法,但对这种风险感到满意)
它看起来对我来说是一个非常好的选择,但我希望能得到一些参考(感觉)在我投入时间将其纳入我的下一个项目之前,可以只说积极的事情!)
目前,我们开发的大中型网站通常使用适量的 Javascript(尽管这一数字正在迅速增长)。我们还使用 jQuery 库来处理大部分 Javascript。
有人有经验吗?好还是坏! :)
PS 对于那些感兴趣的人 这是 head.js
Things I am aware of:
-
Screen flicker if scripts alter styles / content (not an issue for me as I currently load scripts at the end of the page and so have workarounds already)
-
Inability to detect script load failure (not too concerned about this either as everything I develop is required to work with or without javascript. Might affect my workarounds for item 1 but happy with this risk)
It looks to be a very good option to me but I am hoping for some references (feel free to say only positive things!) before I invest time in incorporating it into my next project.
Currently we develop mid-to-large sized sites with, generally, a moderate amount of Javascript (although this is growing rapidly). We also use the jQuery library for the bulk of our Javascript.
Anyone have any experience? Good or bad! :)
P.S. for those interested this is head.js
发布评论
评论(5)
没有。只要您将任何依赖于加载文件的代码放入 head.ready {} 中,那么您的代码就不会遇到任何问题。
Nope. As long as you put any code that is dependent on the loading files inside head.ready {} then you will not face any problems with your code.
这是我对 head.js 的结论,我自己做了一些基准测试:
http://blog.feronovak.com/2011/03/headjs-script-is-it-really-necessary.html
这是主观意见,基准绝对不科学。
Here is my conclusion for head.js, I have done some benchmarks myself:
http://blog.feronovak.com/2011/03/headjs-script-is-it-really-necessary.html
It is subjective opinion and benchmarks are not by any means scientific.
我有兴趣并考虑也许也使用 head.js 但我发现了一些不太好的东西:在您给我的网址中,有三个选项卡按钮:
Shift+Ctr+Refresh 对我来说几乎没有什么区别(+/-三个 @ 120mbit 线之间有 10ms,firefox 3.6.13)
当我使用 Ctr+R 刷新时,head.js 上的结果始终比其他两个没有 head.js 的版本慢 100ms... 所以,它并不总是更快。
I was/am interested and thinking of maybe also using head.js BUT i found something not so nice: In the url that you gave me there are three tab buttons:
Shift+Ctr+Refresh gives very little differences for me (+/-10ms between the three @ 120mbit line, firefox 3.6.13)
When I use Ctr+R refresh, the results on the head.js are consistently 100ms slower than the other two versions without head.js... So, its NOT always faster.
大量使用 jquery 或 javascript 库不会有问题。尝试让每个库都是独一无二的。
我正在使用prototype、scriptaculous、jquery 和更多jquery 附加插件。我在加载整个脚本时遇到错误。然后我发现这是由于$符号,它是jquery和prototype的重要参数。
我曾经使用过
所以请保持你的脚本库独特
There would be no problem on using jquery or javascript library heavily. Try to main each library as unique.
I am using prototype, scriptaculous, jquery and many more jquery additional plugins. I faced an error while loading entire scripts. Then i found out its due to $ sign which is an important parameter of jquery and prototype.
i had used
So keep your script library unique
head.js()
给我的页面带来了问题。我的asp:button
OnClick 事件都不起作用。但是,如果我以传统方式包含脚本 (head.js()
gave a problem to my pages. None of myasp:button
OnClick events were working. But if I include the scripts in the traditional way (<script type="text/javascript src=""
) then the events worked perfectly. I triedEnableClientScript = "false"
and alsoCausesValidation="false"
. But nothing worked. Finally just scrapped the head.js idea since it did not make a lot of difference to my page load time, anyway.