
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Should I Always Put My JavaScript File in the Head Tag of My HTML File?
You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the <head> tag or <body> tag.
It’s good for performance to add JavaScript in <body> element. Here’s an example to add <script> under <body>…</body> −
<html> <body> <script> <!-- document.write("Hello World!") //--> </script> </body> </html>
Here’s an example to add <script> under <head>…</head> −
<html> <head> <script> <!-- document.write("Hello World!") //--> </script> </head> <body> </body> </html>
Advertisements