wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript" Watch "JavaScript" New topic
Author

JavaScript

srikanth ladi
Greenhorn

Joined: Dec 28, 2011
Posts: 3
what is difference using <script> at <head> block or <body>?
Ifteqar Ahmed
Ranch Hand

Joined: May 02, 2011
Posts: 85

If you write <Script> inside <head> tag You Will Seperate the javascript code from HTML Codes so it would be a structured Code..
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ifteqar Ahmed wrote:If you write <Script> inside <head> tag You Will Seperate the javascript code from HTML Codes so it would be a structured Code..


That's not accurate.


The problem caused by scripts is that they block parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames.

In some situations it's not easy to move scripts to the bottom. If, for example, the script uses document.write to insert part of the page's content, it can't be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround these situations.

An alternative suggestion that often comes up is to use deferred scripts. The DEFER attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn't support the DEFER attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.


source


GenRocket - Experts at Building Test Data
 
Don't get me started about those stupid light bulbs.
 
subject: JavaScript