简体   繁体   中英

Are there any drawbacks to using 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! :)

PS for those interested this is head.js

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.

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.

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.

There maybe an issue when you have JS links/actions on the page. They won't work (or work like there is no JS) before the scripts fully load. This may or may not be an issue, depending on how you structure that.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM