As a beginner, it is a bit confusing to understand web technologies. The problem is that most of us don’t know where to start when it comes to coding and programming. Or how to put things together to make things happen.
The same is not true for any web expert or front-end developer who has years of expertise.
<head> .... .... <!-- just before the closing head tag---> </head> <body> .... .... <!-- or just before the closing body tag (Recommended)---> </body> <footer> .... .... <!--or just before the closing footer tag---> </footer>
This is because it provides a good user experience at the time of page load. If you do so, the script only gets loaded after the text, CSS and other important page elements have been loaded.
But, If a page has too many JS scripts in the head section. Then there will be a significant response delay and rendering of the page. This leads to the slowing down of web pages causing a bad user experience. As a result, high bounce rate.
<script> // any js code </script>
If you are having a JS file in your local project folder then you can use the
src attribute to the link. In order to link it, you must specify the local path of the Js file.
For example, link a jQuery library to your HTML project.
Note: The delivery of the JS file is over a network.
<script src="https://code.jquery.com/jquery-3.6.0.min.js" />
Note: We didn’t use the closing tag script instead just used /> at the end. However, it is completely valid to use the last closing tag instead of just using /> at the end.
Like this article? Follow us on Facebook and LinkedIn. You can also subscribe to our weekly Feed