使用 head.js 有什么缺点吗?

发布于 2024-10-08 18:20:04 字数 491 浏览 1 评论 0 原文

我知道的事情:

  1. 如果脚本改变样式/内容,屏幕会闪烁(对我来说不是问题,因为我目前在页面末尾加载脚本,因此已经有了解决方法)

  2. 无法检测脚本加载失败(不太担心这一点,因为一切我的开发需要使用或不使用 javascript。可能会影响我对第 1 项的解决方法,但对这种风险感到满意)

看起来对我来说是一个非常好的选择,但我希望能得到一些参考(感觉)在我投入时间将其纳入我的下一个项目之前,可以只说积极的事情!)

目前,我们开发的大中型网站通常使用适量的 Javascript(尽管这一数字正在迅速增长)。我们还使用 jQuery 库来处理大部分 Javascript。

有人有经验吗?好还是坏! :)

PS 对于那些感兴趣的人 这是 head.js

Things I am aware of:

  1. 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)

  2. 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

自由范儿 2024-10-15 18:20:04

没有。只要您将任何依赖于加载文件的代码放入 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.

寂寞陪衬 2024-10-15 18:20:04

这是我对 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.

记忆之渊 2024-10-15 18:20:04

我有兴趣并考虑也许也使用 head.js 但我发现了一些不太好的东西:在您给我的网址中,有三个选项卡按钮:

SCRIPT          SCRIPT SRC     head.js 
SRC in head     on bottom      on head 

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:

SCRIPT          SCRIPT SRC     head.js 
SRC in head     on bottom      on head 

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.

情感失落者 2024-10-15 18:20:04

大量使用 jquery 或 javascript 库不会有问题。尝试让每个库都是独一无二的。

我正在使用prototype、scriptaculous、jquery 和更多jquery 附加插件。我在加载整个脚本时遇到错误。然后我发现这是由于$符号,它是jquery和prototype的重要参数。

我曾经使用过

    $.noConflict();
jQuery(document).ready(function($){
//jquery codes here
})

所以请保持你的脚本库独特

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

    $.noConflict();
jQuery(document).ready(function($){
//jquery codes here
})

So keep your script library unique

热血少△年 2024-10-15 18:20:04

head.js() 给我的页面带来了问题。我的 asp:button OnClick 事件都不起作用。但是,如果我以传统方式包含脚本 (

head.js() gave a problem to my pages. None of my asp: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 tried EnableClientScript = "false" and also CausesValidation="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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文