Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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! :)

P.S. for those interested this is head.js

like image 706
Stuart Burrows Avatar asked Dec 21 '10 10:12

Stuart Burrows


People also ask

Is it better to put JavaScript in head or body?

The best practice is to put JavaScript <script> tags just before the closing </body> tag rather than in the <head> section of your HTML. The reason for this is that HTML loads from top to bottom. The head loads first, then the body, and then everything inside the body.

Should JavaScript be in head?

You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the <head> tag or <body> tag.

Should jQuery go in head or body?

It's always a good practice to add jQuery code in footer i.e. just before the closing </body> tag. If you have not done that, then use the defer attribute.

Does jQuery need to be in head?

Step 2: Create an HTML file and Declare the jQuery file path in the <script> tag inside the <head> tag section of the HTML file. Note that the jQuery file must be placed inside the workspace.


2 Answers

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.

like image 78
Phil Sturgeon Avatar answered Sep 21 '22 12:09

Phil Sturgeon


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.

like image 30
feronovak Avatar answered Sep 23 '22 12:09

feronovak