ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2014/11/30
waqas Ajaz
من قبل 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
من قبل 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
من قبل 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
من قبل 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
من قبل waqar mahmood , Senior Software Engineer / Team Lead , amazon foods

because script load after a content 

Gurjant Singh Pannu
من قبل 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.

مستخدم محذوف‎
من قبل مستخدم محذوف‎

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

 

المزيد من الأسئلة المماثلة