Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Why we put script link at the button of HTML tags before the </body> tag ?

user-image
Question added by Deleted user
Date Posted: 2014/11/30
waqas Ajaz
by waqas Ajaz , IT Coordinator , Dolphin Holding WLL

basic answer: </body>sends a command to the browser, " there is no more content to show or function". end of story.

 

 

I couldnt write a lot of details, so for a detailed answer, kindly have a lok at this: http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup

 

 

Rahaf Nawash
by Rahaf Nawash , Front End Engineer , Atypon Systems Inc.

where else to put it ?! script tags can be put in two places either the head or either the body.

However, placing the script tag at end of body is a good practice as it improves the performance of the page loading since on JavaScript calls, the parser blocks other HTML on your page. so its better to be called after all other components have been loaded.

islam khalil
by islam khalil , Technical Manager , iCloudit

a lot of reasons to do that , but the most important one:

Javascript file block all other http requests until the JavaScript  file is downloaded.

Basm Allah Alrahman Alrahim

 

Consider that you want to make script function execute to assign the color of a navigation menu , what will happen if you put this function at the <head> <script>  tag , it will be executed before the menu exist ( render to html <body> dose not start yet )so nothing will happens

 

Note

the execution done sequentially line by line

Maged Rawash
by Maged Rawash , Senior UI / UX , Nazzelha

you can't start working (your script) on HTML tags that is not parsed yet.so we put the script in the end of the tag to force browser to read html and then allow script to be applied on html . 

waqar mahmood
by waqar mahmood , Senior Software Engineer / Team Lead , amazon foods

because script load after a content 

Gurjant Singh Pannu
by Gurjant Singh Pannu , Software Development | Project Manager , Webs Maven, Mohali

The <body> tag defines the documentation of body.

The <body> element contains all the contents of an HTML document.

because script   is we can type in body tag only

Sir because we give reference or in other words we can say that the mapping is done.

we use CSS and other scripting file for look and feel to our HTML pages. Hence in order to use that file we do mapping and give reference to that file.

The <body> element contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc.

 

becz we using that tag ..which contents we want in body section means ...we use that body tag

 

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.