Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Where is the best place to put JavaScript in the HTML?

I am currently learning web development, and I'm currently learning JavaScript. And I have a question, where is the best place to put JavaScript (script tag) in the HTML?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try to put all your JavaScript after your HTML code. The most common thing to see today is to place it in a separate file and use a script tag with a source file in it. <script src='main.js'></script>

Or just placing it within the script tag. <script>..code..</script>

The reason that you need these tags after your HTML, so on the last line of your body, is so that when you need to get something from the DOM, you know it has been loaded in already.

about 4 years ago · Juan Pablo Isaza Report

0

Here is an Answer from the w3schools website:

JavaScript in <head> or <body>
You can place any number of scripts in an HTML document.

Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.

Here is the link to the mentioned answer:

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!