62788/generally-position-between-head-head-script-just-before-body
The main reason as to why JS files are linked at the bottom of the body is because whenever a browser encounters any JS, it parses it and executes that on the spot. Hence if it was to be added at the top, it would make the page rendering slow and thus it would take more time for page load. Moreover since the DOM won't be rendered fully, JS won't be able to manipulate the elements.
However if you use Jquery, that won't be an issue since it would execute only after the document is ready. But since in any case, the browser would parse it, it would slow the page load.
On the contrary, CSS files are linked in the head because they get applied regardless of DOM already rendered or not. Hence the webpage looks elegant as soon as the page loads. However just like JS you can link the CSS at the end which would mean that the webpage first loads with just plain HTML and then the CSS is applied to it. This shift is clearly visible to the user and moreover an important thing to remember is that the page would load with bare minimum HTML and if the user has slow Internet connection, the CSS load would take considerable amount of time, which means that the webpage shows just the HTML meanwhile. This might make the user close the website without waiting for it to load fully.
To avoid such things, a CSS file is linked at the head while a JS file is linked at the bottom.
Hope this might help you to understand the importance of it. You can follow this link https://www.edureka.co/complete-web-developer.
The simplest thing to do in the ...READ MORE
i find a topic about difference between ...READ MORE
What is the difference between margin and ...READ MORE
Set the time limits for how long ...READ MORE
How to pass command line arguments to ...READ MORE
How to run a function in a ...READ MORE
You can use CSS and conic-gradient for ...READ MORE
Feature Margin Padding space location An element's outer space, beyond its ...READ MORE
A favicon is your website logo that ...READ MORE
This is basically done using Facebook Pixel. Facebook ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.